相关疑难解决方法(0)

从 HAProxy 发送 PROXY 协议标头

我可能已经迷失在关于这个主题的大量文档中,但我正在尝试配置我的 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)

high-availability load-balancing haproxy

3
推荐指数
1
解决办法
2万
查看次数

通过 Haproxy 转发真实 IP => Nginx => Unicorn

如何将真实访客的 IP 地址转发给 Unicorn?目前的设置是:

Haproxy => Nginx => Unicorn
Run Code Online (Sandbox Code Playgroud)
  1. 如何将真实 IP 地址从 Haproxy 转发到 Nginx,再到 Unicorn?目前它总是只有 127.0.0.1
  2. 我读到 X 标头将被弃用。http://tools.ietf.org/html/rfc6648 - 这将如何影响我们?

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)

http nginx haproxy unicorn

2
推荐指数
1
解决办法
9717
查看次数