One domain but two different servers


I have one domain lets say: I have a CNAME for it that points to my Heroku server lets say:

Now I have one more heroku server

I want my requests to go like this:*  ->* ->

But the url should be the same ie. for all cases. Ie not a redirect that change the url to Is this possible to do using Cloudflare?

Today I have a reverse proxy in my but this causes all requests to go via I would like to have Cloudflare to do that selection instead resulting in no web requests to reach so I can remove the reverse proxy at my side.

That’s certainly a non-standard configuration. A hostname points to an IP address, so everything below that should be on the same server.

However, if you want to dig into Workers to pull subdirectory data from a different server, you can try something like this:

Oh I see. But is it really that uncommon to have your web, backend, blog etc on different servers but you still want the same domain?


Anyhow. Thanks for the tip with workers. Might work with my use case. I solved it in another way for now.

I started a new, third, heroku dyno where I deployed a HAProxy. In the proxy config I pointed all requests to /api* to my dyno and the rest to
Then I “moved” the domain to the proxy dyno and changed the dns target to the proxy dyno here on cloudflare so all traffic pass trough it and gets redirected properly. Seems like it plays along nicely. Just thought I could do that directly on cloudflare and skip the third dyno :slight_smile:

If you are on an Enterprise plan you use the Resolve Override page rule. You may need to use Host Header Override The limitation is that the public and origin paths must match. If you cannot work with this limitation, you will have to use a worker.


This topic was automatically closed after 31 days. New replies are no longer allowed.