When building a website, it is important to consider issues related to image storage and traffic.

Initially, I stored the images and website on the same web server, but later found that the server space was often insufficient (because the system automatically backed up, causing insufficient space).

Later, I placed the images on OneDrive Business Edition and used it with OneList, but since it was an unofficial API, when the API request rate was too fast, the images failed to load.

After the failure of OneDrive, I placed the images on Google Drive and used it with rclone, but… the website loading speed was slow! (And traffic also exploded) Finally, I found Backblaze B2 XD

What is Backblaze?

Backblaze is a data storage provider that offers two products:

  • B2 Cloud Storage is an object storage service similar to Amazon S3, which is cost-effective and comes with free egress traffic when used with Cloudflare CDN!
  • Cloud Backup is an unlimited space computer backup service.

If you are interested in learning more, please refer to the Backblaze website.

Resources Required

  • Cloudflare CDN
  • Cloudflare DNS
  • Cloudflare Workers
  • Backblaze B2

Tutorial

  1. First, go to Cloudflare and click + Add a Site to add a domain.

  1. After adding, click Workers on the right to enter Cloudflare Workers. Then click Create a Worker to create a new Worker.

  1. Paste the code at the bottom of the article into the left Script and modify the following three parameters:
  • b2Domain
  • b2Bucket
  • b2UrlPath

After completion, click Save and Deploy below.

  1. Then we enter the newly added domain and add a CNAME record (the following is an A record… I forgot to change it xDD).

  1. After adding the CNAME record, click Workers above, then click Add route.

  1. Next, we need to set it up.

  2. Fill in the newly added subdomain/* part of the Route, e.g. img.steveyi.net/*.

  3. Choose the newly added Worker for Worker.

That’s it!

Cloudflare Workers Code

Code Author / Source

'use strict';
const b2Domain = 'static-a1.steveyi.net'; //The Backblaze domain you want to bind to Cloudflare.
const b2Bucket = ''; //The storage bucket name of Backblaze B2
const b2UrlPath = `/file/${b2