Search code examples
proxyload-balancinghaproxy

Adding url path to backend HAPROXY


I want to add a path to url if only no path defined. E.g.

hostname:8080 -> then add /fe: -> hostname:8080/fe

The answer from https://stackoverflow.com/a/40488319/12501050 does not work:

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

as it blocks the other requests. E.g.

hostname:8080/fe/getUsers


Solution

  • This part is little tricky to implement, but not that hard to work. Something like this works.

    acl p_root path -i /
    acl is_domain hdr(host) -i myhostname.io
    redirect code 301 location myhostname.io/fe if is_domain p_root
    

    Hope this is helps.