Serve url on any subdomain

I have an app deployed at https://foo.example.com/__debug and I would like to have all urls that match /_debug/* on ANY of our subdomains (IE bar.example.com, baz.example) to be routed behind the scenes (NOT redirected) to that url. For instance, if someone goes to https://bar.example.com/__debug/cookies I want Cloudflare to basically change the backend to the foo.example.com ip and served the page really at https://foo.example.com/__debug/cookies If I were doing this in HAProxy, I would create an acl acl debug ^\/__debug/.* with use_backend foo if debug
7 Replies
bnason
bnasonOP5w ago
Would that be an Origin Rule? With expression of(starts_with(http.request.uri.path, "/__debug")) and then Host Header Rewrite, SNI Rewrite, and DNS Record Override pointing to foo.example.com?
David Wang
David Wang5w ago
What about a wildcard A Record pointing to that ip and just doing the rewriting at the server?
bnason
bnasonOP5w ago
We do not have a single load balancer in front of all the subdomains. Some are hosted internally while some are hosted by our software vendoer and we don't have any control over their lbs The only thing in front of them all is CloudFlare
Hello, I’m Allie!
Are you using Workers already?
bnason
bnasonOP5w ago
Not yet. I tihink I could also accomplish this via Workers AND snippets? Is there any benefit either way?
Hello, I’m Allie!
Both are free(assuming this is all you want to do). Workers Assets has slightly higher file-size limits, given that you want to embed the contents of the file in the Worker/Snippet
bnason
bnasonOP5w ago
I think the Origin Rule I setup is working. I have to modify my app to add a base tag in the head so that all my scripts/images are properly loaded however. All that could be done in a worker/snippet but this seems to be the easier option for now.
Want results from more Discord servers?
Add your server