Backblaze B2: Affordable Object Storage with CloudFlare CDN Integration

backblaze b2cloudflare cdn integrationcheap object storageimgurl procloud storage backup
Published·Modified·

I first learned about Backblaze B2 from a comment on the ImgURL image hosting site. Currently, ImgURL Pro supports this storage method. Click here to view the ImgURL Pro introduction.

Backblaze was founded in 2007, initially focusing on helping users back up their computer data completely. However, it has since expanded to protect businesses and provide B2 cloud storage for developers and IT professionals, which is the main subject of this article.

About Pricing

After comparing several object storage providers, I found that Backblaze B2 is indeed very affordable, costing only 1/4 of Amazon AWS S3. If you need a low-cost storage solution, consider Backblaze B2. Below is a price comparison.

Registering for Backblaze

Backblaze B2 offers 10GB of free storage for each user. If you need it, you can register at https://www.backblaze.com/.

Enabling CloudFlare CDN

The download traffic fee for Backblaze B2 is $0.01/GB. Although this is already cheap, to save as much as possible, we can follow the official blog's method to connect B2 with CloudFlare CDN for caching, thereby further reducing traffic costs.

  1. First, add your own domain on https://www.cloudflare.com/ and complete the integration as prompted.

  2. For example, if the domain integrated into CloudFlare is b2-test.bmp.ovh, you need to resolve the domain to the B2 domain f002.backblazeb2.com using a CNAME record in CloudFlare.

  3. Then, open CloudFlare - Page Rules - Create Page Rule and create a page rule as shown below.

The rewrite rule should be your domain + /file/ + b2 bucket name + /*. For more details on integrating with CloudFlare, refer to the official blog: Using Backblaze B2 with the Cloudflare CDN.

Setting Up Backblaze B2

Although CloudFlare CDN is enabled, I found that the cache was never hit (MISS). We need to add a cache instruction (caching is disabled by default). Open the bucket settings and set the bucket information to {"cache-control":"max-age=43200"}. Here, 43200 is in seconds (s), meaning CloudFlare will not fetch resources from the origin server again within 43,200 seconds.

Using the browser F12 debugging tool, we can see that the request has hit the CloudFlare cache, as shown in the screenshot below.

Summary

Backblaze B2 servers are located in the US, making them suitable for use with US-based VPS; otherwise, speeds may be slow. Backblaze B2 is low-cost and is a great solution for storage and VPS data backup (the official API is provided). You can also purchase ImgURL Pro to use Backblaze B2 as an image hosting service.

Some content in this article is referenced from: Cache Images from BackBlaze B2