linux - HAProxy tcp模式源客户端ip
问题描述
我在 HAProxy 中有以下设置
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
defaults
log global
retries 2
option dontlognull
timeout connect 10000
timeout server 600000
timeout client 600000
frontend https
bind 5.x.x.x:443
default_backend https
backend https
mode tcp
balance roundrobin
option tcp-check
server traefik 192.168.128.5:9443 check fall 3 rise 2
它按预期工作,后端服务器“traefik”正在对请求进行 SSL 终止。
问题是我在后端服务器中获得的客户端源 IP 是 HAProxy 的 IP,我想将源 IP 传递给后端服务器。
有可能吗?因为我尝试了我在互联网上看到的所有选项。
谢谢。
解决方案
最后,解决方案是使用https://www.haproxy.com/blog/haproxy/proxy-protocol/,因为它受到 HAProxy 和 traefik 的支持。
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
defaults
log global
retries 2
option dontlognull
timeout connect 10000
timeout server 600000
timeout client 600000
frontend https
bind 5.x.x.x:443
default_backend https
backend https
mode tcp
balance roundrobin
option tcp-check
server traefik 192.168.128.5:9443 check fall 3 rise 2 send-proxy
并启用 traefik 的入口点代理协议,如下所述:https ://docs.traefik.io/configuration/entrypoints/#proxyprotocol
推荐阅读
- python - 从 python 字典中的多个键中删除重复的值项并附加到新字典
- sql - 使用 AND 运算符的 Oracle 更新问题
- javascript - 将阅读更多按钮添加到字符串 html 反应
- angular - 无法在角度指令中删除事件监听器
- javascript - 如何在Angular中传递基于接口的属性
- java - 没有中间变量,泛型代码无法编译
- c# - 事件查看器 - 使用 C# 添加自定义事件数据属性
- html - 离子应用程序 - 离子服务问题
- c# - 如何在客户端计算机上将 Windows 服务作为控制台应用程序运行
- amazon-web-services - TSV 作为 sagemaker 的输入