在nginx 1.11后面的版本中nginx stream proxy中增加了一个transparent。
具体使用如下
proxy_bind $remote_addr transparent;
官方的解释如下,有点看不懂。
The transparent parameter (1.11.0) allows outgoing connections to a proxied server originate from a non-local IP address, for example, from a real IP address of a client:
In order for this parameter to work, it is usually necessary to run nginx worker processes with the superuser privileges. On Linux it is not required (1.13.8) as if the transparent parameter is specified, worker processes inherit the CAP_NET_RAW capability from the master process. It is also necessary to configure kernel routing table to intercept network traffic from the proxied server.
那我们就测试一把, 建了一个dns的负载均衡。