haproxy+nginx相关的配置
haproxy tcp模式 + nginx http模式 ,nginx打印客户端源IP
haproxy 增加 send-proxy参数,用于启用代理协议(Proxy Protocol)支持
listen nginx-web bind 0.0.0.0:80 mode tcp option tcplog balance roundrobin server nginx-1 server1:81 check inter 10000 fall 2 rise 2 weight 1 send-proxy server nginx-2 server2:81 check inter 10000 fall 2 rise 2 weight 1 send-proxy server nginx-3 server3:81 check inter 10000 fall 2 rise 2 weight 1 send-proxy
nginx http模块,增加打印$proxy_protocol_addr变量,即代理协议传递的客户端IP地址
http { map $http_upgrade $connection_upgrade { default upgrade; '' close; } log_format main '$proxy_protocol_addr - $remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
nginx server模块,增加proxy_protocol配置,并启用了Proxy Protocol支持,这意味着它预期从HAProxy那里接收使用Proxy Protocol传递的请求。此配置确保Nginx可以正确地识别代理的客户端IP地址。
server { listen 81 default_server proxy_protocol;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?