gpt4 book ai didi

openshift - X-Forwarded-Host header 在已设置时不应被 HaProxy 覆盖

转载 作者:行者123 更新时间:2023-12-05 03:58:20 30 4
gpt4 key购买 nike

有人能告诉我如何在 openshift 3.11 中配置自定义 ha 代理路由器(haproxy-config.template),避免 X-Forwarded-Host、X-Forwarded-Port 和 X-Forwarded-Proto header 不应该被覆盖HaProxy 已经设置好。不设置header时,按照HTTP标准设置。

我试过了 https://access.redhat.com/solutions/3986281但它不工作。

谢谢,桑托斯

最佳答案

下面的代码对我有用:

旧配置:

   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

关于openshift - X-Forwarded-Host header 在已设置时不应被 HaProxy 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58092451/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com