HAProxy community

Rewrite inbound and outbound


Hopefully this will be a simple config

I want to be able to have 2 websites using the same URL but split by suburl i.e.


However the website themselves are not configurable to be accessed by the sub directories and have to access from ht.tp://mywebclient

The server backend are running on different IPs, so I have been able to split them via url beg

acl Webconsole_dev path_beg /dev
acl Webconsole_qa path_beg /qa

However I need the traffic sent to each webserver to be in the format of http://mywebclient and then when it returns traffic to the client through the haproxy it needs to rewrite the information so that it goes back in the original request url.

So for example
request in ht.tp://mywebclient/dev/ —> send to dev backend as ht.tp://mywebclient

return response from dev backend ht.tp://mywebclient --> sent out through haproxy as ht.tp://mywebclient/dev/

Hope that makes sense.

Sorry for the mis formed http but it said I cant post links




The response doesn’t contain the URL, so you don’t have to rewrite anything there.

You can just rewrite the request with reqrep, that should do it.


For information this is whats required

reqrep ^([^\ ]\ /)dev[/]?(.) \1\2
rsprep ^([^\ ]\ /)(.) \1dev/\2

However this doesnt seem to rewrite all the content of the response.


It only works for headers, not the body, no.