X-Forward-Proto https .
X-Forward-Proto https
在 我试图在 使用:
frontend haproxy bind :8443 ssl crt frontend/server.pem reqadd X-Forwarded-Proto:\ https default_backend my-backend
这似乎使它工作-例如,我可以登录到我的后端服务器和导航到不同的页面。如果我没有proto选项,我只能登录,但不能导航到任何其他页面。
后端 而是(从前端移除)使用:
backend my-backend http-request add-header X-Forwarded-Proto https if { ssl_fc } server my-backend 127.0.0.1:9000
那么,哪种方法是正确的呢?是在前端还是在后端还是无关紧要?
没关系。当您有多个后端时,通常在前端执行此操作是有意义的。
你也可以用 http-request set-header X-Forwarded-Proto 在前端,而不是使用 reqadd .
http-request set-header X-Forwarded-Proto
reqadd
req* 指令的功能比 http-request 一般来说,后者是首选的,但是有一个重要的原因,为什么你应该选择它,这里还有为什么你应该使用 set-header add-header :您不希望客户端能够伪造只有代理应该注入的头。对于非https前端,还应该 http-request set-header X-Forwarded-Proto http 这样就不可能有不正确的上游报头。这个 选项,就像 请求添加 设置页眉
req*
http-request
set-header
add-header
http-request set-header X-Forwarded-Proto http
请求添加
设置页眉