Configuring Cloudflare and B2
Currently B2 only supports the use of our "standard" URL structure when accessing your B2 files, i.e. f000.backblazeb2.com.
This article helps you configure Cloudflare to front a public B2 bucket. This will allow you to use your domain name, instead of f000.backblazeb2.com.
Using the Cloudflare service in conjunction with B2 will enable you to display your own URL while still storing files on B2.
Browse the public bucket you want to share
Login to your Backblaze B2 account, browse into the bucket you wish to share. From there, click the information icon.
Discover your B2 public URL
The URL to display the file should be either https://f000.backblazeb2.com, https://f001.backblazeb2.com or something similar. Clicking on the link should take you to the image. (If you receive a permissions error - ensure your bucket is public.)
Sign up for an account on Cloudflare
Visit https://www.cloudflare.com/a/sign-up and Signup for an account.
Add a website
Add your domain to the bottom of the screen and tap scan. Cloudflare will read your domain's configuration from DNS. When the scan is complete, push Continue.
Add a DNS record
- Select CNAME from the record type pulldown.
- Type your hostname. For example, if you want the bucket to be mapped to photos.mydomain.com, the Name field would be photos.
- Specify the B2 public URL, from the first step. For example, f000.backblazeb2.com.
- Push "Add Record".
Complete DNS record
- Tap the grey cloud under Status. This should turn it into an orange cloud.
Push Continue at the bottom of the page.
Select the billing plan that's appropriate for you. The free website option works with B2 and can be used. Push continue to go on.
Change your nameservers
In order for Cloudflare to map your domain on a B2 bucket, you need to change CloudFlare to be the domain name servers for your domain. Generally speaking, you need to do this from your domain registrar's website. Be careful when changing the settings for your domain. If you don't do this correctly - your domain could be temporarily removed from the internet.
Once this change is made - it can take at most 24 hours for the changes to propigate across the internet.
Ensure you SSL settings are correct.
Ensure your SSL settings are set to Full. This is the default setting.
When your DNS changes are propagated, your domain can be used to serve data out of a B2 bucket. The Cloudflare configuration screen will show the Status as being active.
Browsing to your domain, followed by /file/<bucketname>/filename will display your file.
For example, from the screenshots above, https://photos.sarahandnilay.com/file/nilayp/img.jpg is mapped to https://f001.backblazeb2.com/file/nilayp/img.jpg
Note that this only works using https:// or SSL. Unencrypted HTTP (http://) is not supported by Backblaze B2.