HAProxy community

Redirection with URL masking

I am new in Haproxy Load Balancing and i am doing okay in redirecting traffic on two different URLs. But unable to mask URL for client end because all I want is to redirect traffic from test.uv.edu.pk to test1.uv.edu.pk and test2.uv.edu.pk without changing URL at client end so that client could not see the backend URLs.

Some of my configurations are shared below:

frontend test
acl is_test.uv.edu.pk hdr(host) -i test.uv.edu.pk
use_backend test_backend_servers if is_test.uv.edu.pk
default_backend test_backend_servers
option forwardfor

 backend test_backend_servers
 mode http
 reqrep ^([^\ ]*)\ (.*) \1\ \2
 balance            roundrobin
server             test1 maxconn 5000 check
server             test2 maxconn 5000 check



You can achieve this by using http-request set-path ... (see the manual). In case of redirects you also need to change the Location header accordingly by using http-response set-header Location ....

However if your actual server generates in the resulting HTML paths that should be “hidden” (and thus rewritten) then HAProxy wouldn’t be able to help you.

I think the best solution is to fix the actual servers into using the proper URL’s else you’ll just create more issues than you are solving.