1、需求背景
java后端业务需要获取到真实客户端访问的IP地址,整个业务流程如下:Haproxy(四层负载转发)--->Ingress服务--->后端JAVA应用
2、Haproxy(TCP四层)获取真实IP
haproxy配置修改,需要在转发server那一行 最后面配置 send-proxy
注意:配置修改完成后先不要重启,等ingress开启proxy_protocol协议后再重启,否则由于ingress为开启proxy_protocol协议后悔导致平台无法访问。
#############################dev环境的feature配置#################################
frontend http\_frontend
bind \*:80
acl is\_http hdr\_beg(host) \*.uihcloud.cn
redirect scheme https if !{ ssl\_fc }
mode http
option httpclose
option forwardfor
reqadd X-Forwarded-Proto:\ https
frontend https\_ingress
bind \*:443
mode tcp
default\_backend https\_dev\_web\_server
backend https\_dev\_web\_server
mode tcp
balance roundrobin
stick-table type ip size 1m expire 30m
stick on src
#