Using Backblaze B2 with the Cloudflare CDN Using Backblaze B2 with the Cloudflare CDN

Using Backblaze B2 with the Cloudflare CDN

Andy Andy

Configuring Cloudflare and B2

The partnership between Backblaze and Cloudflare enables storing content on Backblaze's B2 storage service and automatically feeding it as needed into Cloudflare's CDN (Content Delivery Network). This permits content to live in Backblaze B2, yet be delivered with the low latency and high speed of one of the world's premier CDNs.  The content consumer sees no difference as they use the same URLs and access the site exactly as before - only with the speed and reliability of Cloudflare.
As a webmaster, however, you can make full use of Cloudflare's capabilities such as Edge cache expire TTL. Another explanation for how to configure edge cache can be found here.

Feed the CDN from a public B2 bucket

Login to your Backblaze B2 account, and locate (or create) the bucket which will contain the content for the CDN.  Please note: the instructions below are how to configure a public B2 bucket for the Cloudflare CDN.  If you would like to allow Cloudflare to fetch content from a Backblaze B2 private bucket, follow the instructions below. Then, read the KB article for how to use Cloudflare Workers to fetch content from a B2 private bucket.

Discover the B2 public URL for this bucket

The URL to display the file should be either, or something similar. Clicking on the link should take you to the image. Please note: If clicking on this link generates and error, the bucket may be private rather than public.  Toggle the bucket's public/private status from the B2 web UI.


Configuring Cloudflare to use B2

Visit and log into your account (Or Signup for an account).


Configure Cloudflare to handle requests to your domain with content from the Backblaze B2 bucket

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 DNS (Domain Name System) records

Each section of a website that is being fed from a Backblaze B2 bucket requires a specific entry.  For example, a site might have separate areas for photos and videos.  Remapping photos looks like this:

  1. Select CNAME (Canonical Name) from the record type pulldown.
  2. Type your hostname. To map the bucket to, the Name field would be photos.
  3. Specify the B2 public URL, from the first step. For example,
  4. Push "Add Record".

Complete the DNS record

Tap the grey cloud under Status. This should turn it into an orange cloud.

Push Continue at the bottom of the page.


Configure Page Rules to allow only your bucket to be fetched from your domain

The DNS configuration maps your domain to any content hosted on Backblaze B2. Therefore, someone can use your domain to fetch content from another customer's bucket. To ensure this doesn't happen, Cloudflare allows you to use Page Rules to scope requests to your bucket.

To configure, click "Page Rules" from the top navigation and add a rule for each bucket allowing Cloudflare to cache that content. The last rule should redirect to a "file not found" page, such as the one on the Backblaze website. 

In the example below, the bucket name is "nilayp". If a request is made to* , Cloudflare will return the content requests. A request to any other bucket will be redirected.




Select the desired Cloudflare billing plan that's appropriate for you. The free website option works with B2 and can be used. For more information about Cloudflare's capabilities, please visit Cloudflare's service plan page. Push continue to go on.


Change the nameservers for the domain

In order for Cloudflare to map your domain on a B2 bucket, Cloudflare must be the domain nameserver for your domain. This is typically done from your domain registrar's website. Please note: 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 until the settings are corrected.

Once this change is made - it can take at most 24 hours for the changes to propagate across the internet.


Ensure the SSL settings are correct.

Ensure your SSL settings are set to Full. This is the default setting.  Please note: Backblaze B2 only supports secure (HTTPS) connections.

If you have any questions regarding how to set your SSL settings in Cloudflare please review:
This article will show you how to make sure that Cloudflare uses SSL to the origin using FULL mode.




Once the DNS changes are propagated, the domain will serve data directly from the Backblaze B2 cloud storage 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, is mapped to

Note that this only works using https:// or SSL. Unencrypted HTTP (http://) is not supported by Backblaze B2.