大网数据广告活动
服务器运维问答

Send PROXY protocol header from HAProxy

· 52CE 我爱测

I've probably got lost in the masses of documentation on this subject, but I'm trying to configure my HAProxy process to send the PROXY protocol header as described at http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt . …

问题原文

原帖链接 · Wad · CC BY-SA 3.0

I've probably got lost in the masses of documentation on this subject, but I'm trying to configure my HAProxy process to send the PROXY protocol header as described at http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt. This is because I am having to write support for the PROXY protocol into a C++ server (in order for it to have access to the client IP/port) and I want to test my code is working properly with the parsing of the PROXY header.

Here is my minimal config file:

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

What I am finding is that when I start HAProxy and connect to 54781, the first data that TestServer at 48080 receives is the data which is sent from my client; it is not the PROXY header described at the link I posted.

Can someone please tell me what I am missing in my configuration that is preventing the PROXY header being sent to my backend server?

已采纳解答

原帖链接 · Wad · CC BY-SA 3.0

After posting on the HAProxy mailing list ([email omitted]) I got the answer that I need to add either send-proxy or send-proxy-v2 to my backend server definitions.

My updated config file has the line:

server TestServer01 10.6.186.24:48080 send-proxy

...which sends version 1 of the PROXY protocol.

To send version 2, change this to

server TestServer01 10.6.186.24:48080 send-proxy-v2

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。