原文網址: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 GIuse if a proxied server bception 適用於IP address ranges.
指定proxy_bind
指令並設定網路介面的IP位址:
Specify the proxy_bind directive and the IP address of the necessary network interface:
<code>location <span>/app1/</span> { proxy_bind <span>127.0</span><span>.0</span><span>.1</span>; proxy_pass <span>http</span>:<span>//</span>example.com<span>/app1/</span>; }</code>
<code>location <span>/app2/</span> { proxy_bind <span>127.0</span><span>.0</span><span>.2</span>; proxy_pass <span>http</span>:<span>//</span>example.com<span>/app2/</span>; }</code>
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:
<code>location /app3/ { proxy_<span>bind</span><span>$server_addr</span>; proxy_pass http://example.com/app3/; }</code>').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教程有興趣的朋友有所幫助。