I have this acl in haproxy:
acl host_app1 hdr(host) -m reg -i ^[^.]+.app.mydomain.com$
Now, I’d like to redirect all requests hitting this haproxy with URLs such as:
==> abc.app.mydomain.com/val1
==> def.app.mydomain.com/val2/val3
==> ghe.app.mydomain.com/val4/val5/val6
redirect to:
==> abc.app.otherdomain.com/val1
==> def.app.otherdomain.com/val2/val3
==> ghe.app.otherdomain.com/val4/val5/val6
How do we achieve this?
hi @iamdeep
You would need a redirect to a rewritten domain preserving the uri of the request, one way you could do this is the following
http-request redirect code 301 location https://%[hdr(host),regsub(mydomain.com,otherdomain.com)]%[capture.req.uri] if <your_access_list>
the regsub function substitutes mydomain.com with otherdomain.com on the host header without altering the subdomains and the captured request uri is appended at the end of the Location header. More experienced users may have more elegant solutions.