How to setup CF as CDN for Backblaze B2

What is the issue you’re encountering

In the following guide it says I can set up the CDN using a free Cloudflare account, but then in order to set up the Hostname redirect it says I need an Enterprise account. Is it possible to use Cloudflare as a CDN without a hostname redirect?

Hi - Pat Patterson here, Chief Technical Evangelist at Backblaze.

You used to be able to do this with a Page Rule in a free account, but then Page Rules were deprecated and we updated that article to use an Origin Rule. We put a note in that section that Origin Rules are a paid feature, but we also need to remove the statement that ‘you can use the “Free Website” option to use with Backblaze B2’.

Backblaze B2’s S3-compatible API needs the host to be set correctly, as we use it to route the request within our infrastructure. Unfortunately, it seems like Cloudflare no longer provides a way to do this free of charge.

[Edited to insert “S3-compatible API” in that second paragraph]

Host header override was always an Enterprise feature, even through Page Rules. I strongly recall that B2 worked without a host header override in the past, though it was recommended to use a Worker to change the path. That usage of a Worker was later replaced with a Transform Rule for public buckets:

and a Worker is still required for private buckets:

Why is this other article linked in the OP requiring host override when the others don’t? What changed to require it if that is indeed required now?

As an additional note, Workers can use a different host when fetching so the above Worker based guide can be used without Enterprise. Though this is not entirely free as Workers require a subscription of at least $5/mo to use after 100k requests/day.

3 Likes

Thanks @Erisa! The first article you linked worked great!

@metadaddy is there a chance this method will stop working at some point, being that we are not setting the host?

Well, this is embarrassing… :face_with_open_eyes_and_hand_over_mouth:

You are quite right, @Erisa, and I should have known better - I wrote both the blog post you cited and the doc article in @harvey’s question. What I think happened was I rewrote the doc article at some point, switched to using the S3 endpoint in the new version, and had to include the host rewrite rule, because B2’s S3-compatible API uses the host header in routing requests (since it typically contains the bucket name), and the B2 Native API does not - you can pass any host header you like, as I just confirmed with curl.

I’ll open a ticket to change the doc article to use B2 ‘friendly’ URLs.

Thanks for pointing that out!

1 Like

No problem @metadaddy, thanks for the clarification!

Origin Rules are free. :wink:

You are correct, @ncano - Origin Rules are free, but the ability to rewrite the host header via an Origin Rule is a paid feature. My bad.

Now that Cloud Connector is out, we’ll consider adding Backblaze to the list of supported providers if there is demand for it. This will simplify the process of setting up routing between Cloudflare and an object storage bucket down to a few clicks.

3 Likes

Nice - Cloud Connectors look very useful!

How do we determine that? I know we have a ton of mutual customers. Maybe I should drop a note in the next Backblaze Developer Newsletter asking them to demand a Backblaze B2 Cloud Connector :wink:

FWIW, given B2’s S3-compatible API, it should be minimal effort to create a Backblaze B2 Cloud Connector using the Amazon S3 one as a base.

BTW - I’m sure this is on your roadmap, but it would be really useful if you could configure the Cloud Connectors with credentials so they can send signed requests to access private buckets. This is quite a common use case, and it seems like overkill to have to deploy a Worker rather than just past in the credentials.

2 Likes

Hi, I encountered the same issue while using Backblaze B2 and Cloudflare and found this place. I am currently using some workarounds to make it work, but the process is much more complicated compared to using Cloud Connect.

I am big fan of Cloudflare and Backblaze, I sincerely hope that Backblaze can be added to list of supported providers. :wink:

2 Likes

Likewise I love the pricing of Blackbaze and would love to use connector simplify the integration with cloudflare

3 Likes

@ncano - it seems like there is indeed demand for it. How do we make it happen?

1 Like

We’re currently focused on shipping R2 integration for Cloud Connector, but Backblaze is something we’ll look into after that. It’s a great suggestion, and we’ll keep it in mind as we move toward GA. :wink:

1 Like