Backblaze B2: Affordable Object Storage with CloudFlare CDN Integration

Publish: 2019-07-21 | Modify: 2019-07-21

I came across Backblaze B2 through a comment on ImgURL image hosting. ImgURL Pro now supports this storage option. You can learn more about ImgURL Pro here.

ImgURL Pro

Backblaze was founded in 2007 with the main focus of helping users backup their computer data. It has now expanded to provide protection services and offer B2 cloud storage for developers and IT professionals, which is what I will mainly discuss in this article.

Pricing

After comparing several object storage providers, I found that Backblaze B2 offers significantly cheaper prices, only 1/4 of Amazon AWS S3. If you are looking for an affordable storage solution, Backblaze B2 is worth considering. Here is a price comparison chart:

Price Comparison

Registering with Backblaze

Backblaze B2 provides 10GB of free storage for each user. If you are interested, you can register at https://www.backblaze.com/.

Enabling CloudFlare CDN

Although the downstream traffic cost of Backblaze B2 is already very low at $0.01/GB, we can further reduce expenses by integrating B2 with CloudFlare CDN. Follow these steps:

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

  2. For example, if your domain integrated with CloudFlare is b2-test.bmp.ovh, you need to create a CNAME record in CloudFlare to point your domain to B2's domain: f002.backblazeb2.com.

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

Page Rule 1

Page Rule 2

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

Configuring Backblaze B2

Even though CloudFlare CDN is enabled, if you notice that the cache is never hit (MISS), you need to add a cache directive (which is disabled by default). Open the bucket settings and set the bucket info to {"cache-control":"max-age=43200"}. Here, 43200 represents the cache expiration time in seconds. This means that CloudFlare will not fetch the resource from the origin server within 43200 seconds.

Bucket Settings

You can confirm that the request hits the CloudFlare cache by checking the browser's F12 debugging tool, as shown in the screenshot below:

Request Hit Cache

Conclusion

Backblaze B2 servers are located in the United States and are suitable for use with US-based VPS providers. Otherwise, the speed might be slower. Backblaze B2 offers affordable pricing and is a good solution for storage and VPS data backup (the official API is available). Additionally, you can use Backblaze B2 as an image hosting solution by purchasing ImgURL Pro.

This article was partially inspired by: Cache Images from BackBlaze B2


Comments