I have a project I’ve thrown together: https://plantsm.art
Just last night I moved all my images to Cloudflare. The process was simple enough, but I would like to serve them on a more personalised sub domain, eg; https://cdn.plantsm.art instead of the provided delivery URL. I’m aware that I can use the cdn-cgi gateway path on my apex, but would prefer a dedicated sub domain. I’m also aware that I can’t create a CNAME and point it to the image delivery domain.
Is there a practical way to achieve what I’d like without running a reverse proxy or something?
Thanks! It makes perfect sense this would work on a subdomain as well. Just didn’t make that mental leap. Apreesh!
Unfortunate that bulk redirect rules are $$$. I could combine the two to mask the cdn-cgi/imagedelivery/${account_id} stuff. This is a good enough solution for now.
Here, I’ve created a new hostname, foo, that doesn’t actually exist: it’s an AAAA record pointing to the special value 100:: with the orange cloud turned on.
I’m taking any request to that host where the path doesn’t already include imagedelivery (to avoid a redirect loop) and redirecting it to the /cdn-cgi/imagedelivery path, with my account hash appended since that will always be the same, and the rest of the path appended to that. It’s not all visible in the screenshot, but the Expression is:
(I’ve changed the domain name for this example, and you should use your own account hash, which is available on the Cloudflare Images page in the dashboard.)
will redirect to the cdn-cgi version with your account hash on them. So the final URL is visible to the end-user if he looks (because it’s a real redirect) but it’s not in your HTML.
Yes, I tried it with a Transform Rule too, which seemed the cleanest way to do it, but it doesn’t like transforming a URL to /cdn-cgi, so I guess the rule comes in the processing chain too late to invisibly transform it.