Deliver Public Backblaze B2 Content Through Cloudflare CDN
    • Dark

    Deliver Public Backblaze B2 Content Through Cloudflare CDN

    • Dark

    Article Summary

    The partnership between Backblaze and Cloudflare means that you can now store content with Backblaze B2 Cloud Storage and serve it to users using Cloudflare's CDN (Content Delivery Network) with no download fees from Backblaze. This means that content can be stored in Backblaze B2 while being delivered with the high speed and low latency of one of the world's premier CDNs. Users access your site with the same URLs as before, but now they enjoy the speed and reliability of Cloudflare. As a webmaster, you can also use Cloudflare features like Edge cache expire TTL.

    Setting up your website with Cloudflare allows your site to serve data from one or more public Backblaze B2 buckets.

    For example, you might own a web page like You can use Cloudflare to set up a file URL like, where the file myimage.jpg is actually stored in your Backblaze B2 bucket at

    To use Cloudflare with a private Backblaze B2 bucket, see Deliver Private Backblaze B2 Content Through Cloudflare CDN.

    Enable Backblaze B2

    Before you begin: You must have a Backblaze B2 Cloud Storage account. You can sign up here. If you already have a Backblaze account and the left navigation menu contains a B2 Cloud Storage section, your account is already enabled for Backblaze B2.

    1. Sign in to your Backblaze account.
    2. In the left navigation menu under Account, click My Settings.
    3. Under Enabled Products, select the checkbox to enable B2 Cloud Storage.
    4. Review the Terms and Conditions, and click OK to accept them. 

    Create a Public Bucket

    You can use an existing public bucket, or you can create a new public bucket. You must select Public as your privacy setting.

    1. Sign in to your Backblaze account.
    2. In the left navigation menu under B2 Cloud Storage, click Buckets.
    3. Click Create a Bucket.
    4. Enter a name for your bucket.
      Bucket names must be at least six characters and globally unique. A message is displayed if your bucket name is already in use.
    5. Select a privacy setting: Private or Public.
      Files that are in a private bucket require authentication to perform an action, for example, downloading. Public buckets do not require authentication so you can easily share files. You can change a bucket's privacy settings at any time.
    6. If applicable, enable a Backblaze B2 server-side encryption key.
    7. If applicable, enable Object Lock to restrict a file from being modified or deleted for a specified period of time.
    8. Click Create a Bucket, and copy the value that is in the Endpoint field; you may need this value for other processes.
    9. Click Lifecycle Settings to control how long to keep the files in your new bucket.

    Upload Files

    You must upload one or more files to your public bucket.

    You can upload files to a Backblaze B2 bucket from your local drive. The maximum single file size that you can upload through the Backblaze B2 UI is 500 MB. If you need to upload larger files, click here for more information. You can also use the B2 Native API or the Command-Line Interface to upload files.

    1. Sign in to your Backblaze account.
    2. In the left navigation menu under B2 Cloud Storage, click Buckets.
    3. In your bucket details, click Upload/Download and click Upload.
    4. Drop your images from your local drive into the dialog box, or manually select your files.
    5. In the left navigation menu, click Browse Files to see your uploaded file and click the image filename to see more details.

    Locate your Bucket Origin

    1. Sign in to your Backblaze account.
    2. In the left navigation menu under B2 Cloud Storage, click Browse Files and navigate to the public bucket that you created.
    3. Click(info) for any file in the bucket.
    4. Copy the origin of the Friendly URL, for example,

    Configure Cloudflare

    Before you begin: You must have a Cloudflare account. You can select the Cloudflare billing plan that is appropriate for you, but you can use the "Free Website" option to use with Backblaze B2. For more information about Cloudflare's capabilities, visit the service plan page.

    1. Sign in to your Cloudflare account, and click Add Website.
    2. Add your domain, and click Scan DNS Records. Your domain is the hostname suffix that is used to retrieve your Backblaze B2 bucket's content through Cloudflare, for example,
    3. Click Continue when the scan is complete.
    4. Click Add DNS Records.
      1. Select a record type, for example, if your site has separate areas for photos and videos, select CNAME.
      2. Enter your hostname, for example, if you want to map your bucket to, enter photos.
      3. Enter the origin of your bucket.
      4. Click Add Record.
    5. For each DNS record that you created, click (status) to enable website traffic routing.
      The icon turns orange.
    6. Click Continue.

    Configure Page Rules

    You must configure page rules to allow Cloudflare to fetch only your Backblaze B2 bucket from your domain. The DNS configuration maps your domain to any content that is hosted on the same Backblaze B2 origin as your bucket so that someone can use your domain to fetch content from another customer's public bucket. To ensure this does not happen, Cloudflare lets you use Page Rules to scope requests to your bucket.

    1. In the Cloudflare top navigation menu, click Page Rules.
    2. For each Backblaze B2 bucket that you want to use with Cloudflare, create page rules to allow Cloudflare to cache your content.

    In the following examples, the domain is, the hostname is photos, and the bucket is mybucket. The URL given in the Forwarding URL rule is, but you may want to use the URL for a similar "file not found" page of your own.

    Rule #1:*
    Cache Level: Standard
    Rule #2:*/*
    Forwarding URL: (Status Code: 302 - Temporary Redirect, Url:

    These rules mean that Cloudflare can cache the contents of your bucket and that no one can use your domain to fetch contents from another public Backblaze B2 bucket. Attempts to do so are instead redirected to the "file not found" page.

    Change the Nameservers for the Domain

    For Cloudflare to map your domain on a Backblaze B2 bucket, you must select Cloudflare as the domain nameserver for your domain.

    1. Allow Cloudflare as the domain nameserver for your website.
    2. Set SSL/TLS to Full (strict). Backblaze B2 supports only secure (HTTPS) connections. For more information, click here.
    3. Click Continue.

    Access your Backblaze B2 Bucket Content Through Cloudflare CDN

    After the DNS changes are complete, the domain serves data directly from your Backblaze B2 bucket. The Cloudflare configuration screen shows the Status as being active.

    Use the format domain/file/<bucketname>/filename to display your file.

    For example, is mapped to

    You must use an https:// (TLS-secured) URL. Unsecured HTTP (http://) URLs are not supported by Backblaze.