Wad*_*Wad 3 high-availability load-balancing haproxy
我可能已经迷失在关于这个主题的大量文档中,但我正在尝试配置我的 HAProxy 进程以发送代理协议标头,如http://www.haproxy.org/download/1.8/doc/ 所述代理协议.txt。这是因为我必须将 PROXY 协议的支持写入 C++ 服务器(以便它能够访问客户端 IP/端口),并且我想测试我的代码在解析 PROXY 标头时是否正常工作。
这是我的最小配置文件:
global
maxconn 4096
defaults
log global
mode http
retries 3
option redispatch
maxconn 2000
timeout connect 5000
timeout client 50000
timeout server 50000
frontend TestServerTest
bind 10.6.186.24:54781
mode tcp
default_backend TestServernodes
backend TestServernodes
mode tcp
# Note there is no 'check' after the below line unlike the others as we don't want to send the
# healthcheck ("OPTIONS / HTTP/1.0"...) string to the TestServer as it doesn't understand it!
server TestServer01 10.6.186.24:48080
Run Code Online (Sandbox Code Playgroud)
我发现当我启动 HAProxy 并连接到 54781 时,48080 处的 TestServer 收到的第一个数据是从我的客户端发送的数据;它不是我发布的链接中描述的 PROXY 标头。
有人可以告诉我我的配置中缺少什么阻止 PROXY 标头发送到我的后端服务器吗?
在 HAProxy 邮件列表 (haproxy@formilux.org) 上发帖后,我得到了需要添加send-proxy
或添加send-proxy-v2
到后端server
定义的答案。
我更新的配置文件有一行:
服务器 TestServer01 10.6.186.24:48080发送代理
...发送代理协议的第 1 版。
要发送第 2 版,请将其更改为
服务器 TestServer01 10.6.186.24:48080发送代理 v2