有人可以告诉我如何在openshift 3.11中配置自定义ha代理路由器(haproxy-config.template),在哪里避免X-Forwarded-Host,X-Forwarded-Port和X-Forwarded-Proto标头不应被覆盖HaProxy(已设置)。如果未设置标头,则应根据HTTP标准进行设置。
我尝试了https://access.redhat.com/solutions/3986281,但是它不起作用。
谢谢, 桑托什
答案 0 :(得分:2)
下面的代码对我有用:
旧配置:
http-request set-header X-Forwarded-Host %[req.hdr(host)]
http-request set-header X-Forwarded-Port %[dst_port]
http-request set-header X-Forwarded-Proto http if !{ ssl_fc }
http-request set-header X-Forwarded-Proto https if { ssl_fc }
更改为新:
acl h_xfh_exists req.hdr(X-Forwarded-Host) -m found
http-request set-header X-Forwarded-Host %[req.hdr(host)] unless h_xfh_exists
acl h_xfport_exists req.hdr(X-Forwarded-Port) -m found
http-request set-header X-Forwarded-Port %[dst_port] unless h_xfport_exists
acl h_xfproto_exists req.hdr(X-Forwarded-Proto) -m found
http-request set-header X-Forwarded-Proto http if !{ ssl_fc } !h_xfproto_exists
http-request set-header X-Forwarded-Proto https if { ssl_fc } !h_xfproto_exists