Hello, I am trying to build a picture bed for my blog. The solution I use is Backblaze B2 cloud storage + Cloudflare CDN.
First, I set up a CNAME resolution to resolve one of my second-level domain names “img” to the server address given to me by Backblaze, so that when I visit https://img.example.com/file/my-bucket-name/file/testpic.png
Will jump to https://f001.backblazeb2.com/file/my-bucket-name/file/testpic.png
to get files.
But I found that the file link provided to me by Backblaze directly contains the name of my bucket. so that even if I use the CNAME URL through Cloudflare’s proxy service, other people can still get the real address of the file.
So I tried to use URL Rewrite in Transform Rules to modify the address.
my goal is change this link https://img.example.com/file/my-bucket-name/file/testpic.png
to https://img.example.com/testpic.png
to hide the bucket name.
But after I modified it, Error 1035 Invalid request rewrite appeared
Can anyone know if something went wrong with me?
Below are the rules I used
(http.request.full_uri contains "img.example.com/" and not http.request.full_uri contains "/file/my-bucket-name")
I have tried to search for errors in the forum and read the instructions but I have not found an answer that helps me.
Below is the address of the article that I have read and may be helpful to you
English is not my native language, so there may be some small mistakes. I’m sorry for that. If you don’t understand what I’m talking about, please feel free to ask, thank you!
I have read this documentation, but it doesn’t mention that there is no need to write the host name, and I didn’t fully understand the example at the time. Now the problem has been solved, thank you very much for your help!
Thanks for solving my problem. When reading the documentation, I did not notice that all the examples did not include the host name, so an error occurred. I have solved the problem after you pointed it out, thank you again for your help!
The URI path must start with a /, so a minimal change of your config would look like this: concat("/img.example.com/file/my-bucket-name",http.request.uri.path)
I just didn’t think the resulting uri.path would work as you were including the hostname in the path, so suggested it be altered also. Finally, using full_uri to match just the hostname is not efficient, and not precise enough to avoid matching requests to other hostnames.
Thanks a lot for your explanation and suggestion. In fact, the reason I used full_uri at the beginning was that I wanted to match the links below to distinguish different resources and sites