我正在运行从本地主机监听端口20008和20009的TileMill。 我想只能通过端口80上的nginx访问20009(使用简单的身份validation)。 我想20008可以从外面“直接”访问。
server { listen 80; server_name localhost; location / { proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:20009; auth_basic "Restricted"; auth_basic_user_file htpasswd; } } server { listen 20008; server_name localhost; location / { proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:20008; } }
显而易见的问题是,nginx无法侦听端口20008 – 它已被TileMill使用。
Restarting nginx: nginx: [emerg] bind() to 0.0.0.0:20008 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:20008 failed (98: Address already in use)
有没有一种方法,Nginx可以外部监听,而不会与其他服务在内部监听冲突? (将localhost更改为服务器的外部IP不起作用。)
更改您的收听声明以包含您的外部IP,例如:
听1.2.3.4:20008;