NGINX 绑定到特定的网络接口,而不考虑 IP 地址
NGINX bind to a specific network interface, regardless of IP address
有没有办法让 Nginx 1.11 绑定到特定接口而不考虑 IP 地址?
我有一个 ISP 提供商的家庭网关;它使用 DHCP 客户端获取其动态 IP 地址。我不知道在 NGINX 配置时那个 IP 地址是什么。
当然,一定有办法让这么好的 HTTP 服务器绑定到特定的网络接口?我知道 Apache 可以。
将您的启动序列编辑为 运行 捕获接口 IP 地址并将其写入格式为 listen <ip>:80
或您想要的任何端口的文件的命令或脚本:
echo "listen $(ip -o -4 a s eth0 | awk '{ print }' | cut -d/ -f1):80;" > /path/to/some/file
然后让您的 nginx 配置包含该文件:
include /path/to/some/file;
显然,您需要确保在 nginx 启动之前捕获 IP。
有没有办法让 Nginx 1.11 绑定到特定接口而不考虑 IP 地址?
我有一个 ISP 提供商的家庭网关;它使用 DHCP 客户端获取其动态 IP 地址。我不知道在 NGINX 配置时那个 IP 地址是什么。
当然,一定有办法让这么好的 HTTP 服务器绑定到特定的网络接口?我知道 Apache 可以。
将您的启动序列编辑为 运行 捕获接口 IP 地址并将其写入格式为 listen <ip>:80
或您想要的任何端口的文件的命令或脚本:
echo "listen $(ip -o -4 a s eth0 | awk '{ print }' | cut -d/ -f1):80;" > /path/to/some/file
然后让您的 nginx 配置包含该文件:
include /path/to/some/file;
显然,您需要确保在 nginx 启动之前捕获 IP。