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
Will jump to
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
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")
Dynamic rewrite to
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!
Have you reviewed this documentation on how to rewrite URL path? This might help.
The expression should look something like this:
(not http.request.full_uri contains "https://img.example.com/file/mysecretbucketname/" and http.host eq "img.example.com")
(Your example would also match
And then the rewrite just rewrites the path, and does not include the hostname.
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 actual error message is due to this config:
The URI path must start with a /, so a minimal change of your config would look like this:
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
But due to the error, I need to simplify it to try to find the reason. I will pay attention to this problem later.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.