原文地址:https://www.nginx.com/resources/admin-guide/reverse-proxy/
原文标题:choosing an outgoing ip address
如果你的代理服务器有多个网络接口,有时候你可能会需要选择特定的源ip地址连接被代理服务器或者上游服务器。如果nginx后面的一个被代理服务器设置为只接受特定ip网络或者ip地址范围的连接,这种配置就能派上用场了。
if your proxy server has several network interfaces, sometimes you might need to choose a particular source ip address for connecting to a proxied server or an upstream. this may be useful if a proxied server behind nginx is configured to accept connections from particular ip networks or ip address ranges.
指定proxy_bind指令并设置网络接口的ip地址:
specify the proxy_bind directive and the ip address of the necessary network interface:
location /app1/ { proxy_bind 127.0.0.1; proxy_pass http://example.com/app1/;}
location /app2/ { proxy_bind 127.0.0.2; proxy_pass http://example.com/app2/;}
ip地址也可以用变量指定。例如,$server_addr变量会传递接收到请求的网络接口的ip地址。
the ip address can be also specified with a variable. for example, the $server_addr variable passes the ip address of the network interface that accepted the request:
location /app3/ { proxy_bind$server_addr; proxy_pass http://example.com/app3/;}
').addclass('pre-numbering').hide(); $(this).addclass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadein(1700); }); }); 以上就介绍了nginx学习笔记——choosing an outgoing ip address,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。