[alibaba/tengine]日志无法记录proxy_protocol_addr

2024-05-15 753 views
3
Question

我已经在配置里设置proxy_protocol on; client --》192.168.90.47:8886--》192.168.91.177:8886-》realserver(192.168.91.179:6666) 但日志里显示为空值,其中192.168.91.177的Nginx配置如下: stream { log_format proxy '$remote_addr $proxy_protocol_addr:$proxy_protocol_port [$time_local] ' '$protocol $status $connection $bytes_sent $bytes_received ' '$session_time "$upstream_addr" "$server_addr:$server_port" ' '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"'; access_log /var/log/nginx/tcp-proxy.log proxy ; #############测试########### upstream proxy_8886 { server 192.168.91.179:6666; } server { listen 8886; access_log /var/log/nginx/tcp_proxy.log proxy; proxy_protocol on; proxy_pass proxy_8886; } } 后端Realserver能看到proxy protocol传来的IP信息: root># nc -l 6666 PROXY TCP4 192.168.90.47 192.168.91.177 56020 8886 PROXY TCP4 192.168.90.47 192.168.90.47 44686 8886 ^C

但第二层代理192.168.91.177无法获得$proxy_protocol_addr的值,日志显示为空: 192.168.90.47 : [17/Feb/2020:14:44:57 +0800] TCP 200 18780 0 51 8.264 "192.168.91.179:6666" "192.168.91.177:8886" "103" "0" "0.478" 图片

请问这是什么原因?我的理解或设置有误吗?

回答

9

$proxy_protocol_addr 应该是proxy_protocol接收端解析拿到的,你这在发送端,肯定拿不到啊