Is it possible to map a different frontend domain to a backend website without the client ever knowing?

Is it possible to use HAProxy to present a different domain (or subdomain) to the client (as represented in the browser’s address bar, for example) than the one that is actually being queried on the website in the backend?

For example: suppose that I had a website at, with two pages: /page1 and /page2. Could I set up a frontend in HAProxy that made it look as if was a real site, when actually it was just translating everything from on a request by request basis? Thus, a request to would return the page from without the end user ever knowing it?

And, if so, could this be done more delicately with subdomains? Could I ask HAProxy to convert any request made to into without the client ever knowing that the whole thing was virtual? So that, for example, a request to took the information from and re-presented it without the end-user seeing the shift?


Perhaps explaining exactly what you are trying to do might make it sound a little less malicious.

Why does this need to be on a request basis?

Ha! It’s not “malicious.” I just wondered, for example, whether HAProxy was capable of virtualizing a subdomain. Suppose that we have a site at, running in NGINX, and it has a section at, I wondered if was possible to make it seem to the client as if that whole section is at when, within the NGINX context, it’s not “really” there.

Having played with this for a while, it seems as simple as (1) sending any requests to to a given backend, while stripping out the /reviews part of the path, and (2) then telling the backend to (a) put that /reviews part back in if the host is and (b) switch out the Host from to when querying the backend server.

I was just thinking through to what extent HAProxy can abstract everything out.

I’m no expert, but I do believe most of what you want is possible.
Not sure you want the client to use url or that you want to embed on a different url. As long as you are in control of both domains it shouldnt be a problem.

This blog should put you in the right direction

1 Like