Transform rule not working


I’ve got something weird going on.

I’ve got some files in a B2 bucket; for example:

I have a CNAME set up that points to

Finally, I have a transform rule that allows for removal of the /file/fsccdn part of the path, like this:

The transform rule I have set up is as follows:

  • Incoming match ( eq "")
  • Path rewrite dynamic concat("/file/fsccdn", http.request.uri.path)
  • Query preserve

When I try and visit this URL in my browser, I get the following 404 (have tried in Firefox, Chrome, Edge)

  "code": "not_found",
  "message": "File with such name does not exist.",
  "status": 404

However, it seems to load just fine if I reference the image in an image tag.

Also, if I download the file on the command line, that works too. Here I am getting the headers using httpie:

> http --headers
HTTP/1.1 200 OK
Accept-Ranges: bytes
CF-Cache-Status: HIT
CF-RAY: 78edbb0e997edcc3-LHR
Cache-Control: max-age=14400
Cf-Bgj: imgq:85,h2pri
Cf-Polished: degrade=85, origSize=59445
Connection: keep-alive
Content-Length: 33179
Content-Type: image/jpeg
Date: Wed, 25 Jan 2023 02:55:34 GMT
Last-Modified: Wed, 25 Jan 2023 02:08:31 GMT
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Report-To: {"endpoints":[{"url":"https:\/\/\/report\/v3?s=nrZu9DS%2Fou5fq0KaM375nZfrg6p9hBIc6ISfnbeLPtbP3DHcvy1krENpBM4r2kfIV3tOxbpdBWOefbvHmj7dO%2BpYUj%2BoDuivlgkM%2FWMDodMXI9uPck0PMpn8MPYFapYdUH97w0awUK1iW2MVu5QU"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Server-Timing: cf-q-config;dur=7.0000005507609e-06
Vary: Accept
X-Bz-Upload-Timestamp: 1633231038000
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
x-bz-content-sha1: unverified:32ba7ca630ff4e386d5efecf981963835c49b0c2
x-bz-file-id: 4_ze7e6e66a1134494f7dc2081c_f100ba06e43b2165d_d20211003_m031718_c001_v0001144_t0038
x-bz-file-name: 10-Vespula-sp-male.jpg
x-bz-info-src_last_modified_millis: 1559681209000

Any idea what’s going on here?

I’ve just found the post here from @metadaddy that addresses a similar issue:

However, in my case I do not have SXG enabled and if I check the accept header in Firefox there is no mention of SXG.

accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8

Could this be a CORS issue? doesnt work for me, FYI, I get the same 404.

I suspect what’s happening here is the host header is incorrect. Your requests are going to the backblaze origin but with a Host header of instead of, causing backblaze to error out as it has no idea what ‘cdn.field…’ is.

We see this typically with cloud providers like AWS, I even wrote about this in a blog last year:

I’ve not personally setup B2, however I know from speaking with the team at Backblaze in the past that they have a few howto guides (e.g. which might help you.

1 Like

@smarsh What I don’t understand is how the files are served if, for example, referenced in an img tag in a web page, but don’t work if directly entered into the URL bar in the browser.

I created a reduced test:

The picture loads fine as part of this page, but if I enter it directly into the browser, I get the 404.

Also, I have set up a separate B2 bucket on a completely separate domain, and using the exact same transform rule. Directly entered URLs work here. E.g. this works:

But this doesn’t:

I can’t see what the difference is.

@smarsh I have set up another domain and B2 bucket from scratch, configured in the same way, and this works fine too:

So it seems to be something particular for the domain that is not working.