【发布时间】:2017-03-31 12:30:53
【问题描述】:
我有一个 ELK 堆栈。在两台 Logstash 主机前,我设置了两个 NGINX 负载均衡器作为透明代理。 UDP 流量很有魅力。 TCP 与配置一起使用:
stream {
upstream syslog {
server sapvmlogstash01.sa.projectplace.com:514;
server sapvmlogstash02.sa.projectplace.com:514;
}
server {
listen 514;
proxy_pass syslog;
}
}
但我得到的是 LB 的 source_ip 和 source_host 而不是输入服务器的 IP。
设置相同的添加proxy_bind $remote_addr transparent; 不起作用,抛出超时。
*1 upstream timed out (110: Connection timed out) while connecting to upstream, client: $SOURCEHOST_IP, server: 0.0.0.0:514, upstream: "$LOGSTASH_IP:514", bytes from/to client:0/0, bytes from/to upstream:0/0
我尝试从这里设置 TPROXY: https://www.nginx.com/blog/ip-transparency-direct-server-return-nginx-plus-transparent-proxy/
Logstash 主机:
route add default gw $NGINX_IP
route del default gw $DEFAULT_GW
NGINX 主机:
# Following nginx how-to
iptables -t mangle -N DIVERT
iptables -t mangle -A PREROUTING -p udp -m socket -j DIVERT
iptables -t mangle -A DIVERT -j MARK --set-xmark 0x1/0xffffffff
iptables -t mangle -A DIVERT -j ACCEPT
iptables -t mangle -A PREROUTING -p tcp -s $LOGSTASH_IP/24 --sport 514 -j TPROXY --tproxy-mark 0x1/0x1 --on-port 0
ip rule add fwmark 1 lookup 100
ip route add local 0.0.0.0/0 dev lo table 100
# Enabling Upstream Servers to Reach External Servers
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
但仍然像以前一样因超时而失败。
获得透明 TCP 主机缺少什么?
【问题讨论】:
-
你解决过这个问题吗?我也有同样的问题
-
不,抱歉 :( 我认为使用专业版可以做到,但我很久以前就把它抛在了后面