In HAProxy (1.5) I have this rule to redirect all requests to a canonical domain:
redirect prefix https://domain.tld code 301 unless { hdr(host) -i domain.tld }
This works fine. However, I also have stats enabled (stats uri /haproxy-stats
). For these I would like to disable the redirect as I need to access specific haproxy machines (they are behind a DNS round-robin) through their own host name.
Is there any way of configuring HAProxy in such a way?
This can be done using an ACL rule:
Using an anonymous ACL works too:
However, it turned out to be not needed at all as HAProxy doesn't apply redirect rules to the stats url; probably I had an old 301 redirect cached.