我可能已经迷失在关于这个主题的大量文档中,但我正在尝试配置我的 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 …Run Code Online (Sandbox Code Playgroud) 如何将真实访客的 IP 地址转发给 Unicorn?目前的设置是:
Haproxy => Nginx => Unicorn
Run Code Online (Sandbox Code Playgroud)
Haproxy 配置:
# haproxy config
defaults
log global
mode http
option httplog
option dontlognull
option httpclose
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
# Rails Backend
backend deployer-production
reqrep ^([^\ ]*)\ /api/(.*) \1\ /\2
balance roundrobin
server deployer-production localhost:9000 check
Run Code Online (Sandbox Code Playgroud)
Nginx 配置:
upstream unicorn-production {
server unix:/tmp/unicorn.ordify-backend-production.sock fail_timeout=0;
}
server {
listen …Run Code Online (Sandbox Code Playgroud)