Rewrite request URI based on Host header in HAProxy
- by DorinC
I would like to set up HAProxy to forward HTTP requests to some backend servers but I need it to also rewrite the URI part based on the Host. I've read through the doc but it seems that reqirep isn't suitable for this purpose. Any idea if this is even possible with HAProxy?
Here are the details of what I'm trying to accomplish:
Requests that come in on:
http://www.original-domain.com/
would be balanced between:
http://server1/domains/www.original-domain.com/
...
http://serverN/domains/www.original-domain.com/
The proxy should be able to handle this for any number of domains (original-domain.com can be anything, it's not limited to a fixed set of values).
For this to work HAProxy would need to rewrite a request like this:
GET /original-uri HTTP/1.1
Host: original-domain.com
to:
GET /domains/original-domain.com/original-uri HTTP/1.1
Host: serverN
and forward that request to one of the internal servers.