Search code examples
proxyhaproxy

Appending Path to Host HAPROXY


I am new to haproxy (actually proxy'ing in general) and I can't figure out how to add a path to my backend. I have my backend defined as:

server server1 ns.foo.com:7170 check

I want to add /web such that the request is directed to https://ns.foo.com:7170/web.

Thanks, Mark


Solution

  • What you need is HTTP rewriting https://www.haproxy.com/doc/aloha/7.0/haproxy/http_rewriting.html#rewriting-http-urls

    Adding this to your backend should solve your problem:

    acl p_root path -i /
    http-request set-path /web if p_root