在HAProxy(1.5)中,我有这个规则将所有请求redirect到规范域:
redirect prefix https://domain.tld code 301 unless { hdr(host) -i domain.tld }
这工作正常。 不过,我也有统计启用( stats uri /haproxy-stats )。 对于这些我想要禁用redirect,因为我需要通过自己的主机名来访问特定的haproxy机器(它们在DNS循环之后)。
有没有什么办法来configurationHAProxy?
这可以使用ACL规则来完成:
acl url_stats path /haproxy-stats redirect prefix https://domain.tld code 301 unless { hdr(host) -i domain.tld or url_stats }
使用匿名ACL也可以:
redirect prefix https://domain.tld code 301 unless { hdr(host) -i domain.tld } || { path /haproxy-status }
然而,事实certificate,根本不需要HAProxy将redirect规则应用到统计信息url; 可能我有一个旧的301redirectcaching。