Windows – nginx not accessible from public IP, but is on 127.0.0.1

nginxwindows

I am trying to set up nginx as a reverse proxy with HTTP Authentication to a site running on IIS. I have modified the http.sys bindings, as well as my IIS site bindings so that nginx can successfully listen on port 80.

When I access http:// 127.0.0.1 from the server I get the nginx HTTP Authentication dialog as expected, and if I provide credentials it proxies to my IIS application as expected. If I access http:// localhost:8080 I get my IIS application as expected.

However, trying to access the site from another machine fails to connect. I've tried completely disabling the firewall but that doesn't do any good either. Here is my nginx configuration:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    server {
        listen       0.0.0.0:80;
        server_name  localhost;

        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://localhost:8080/;
            auth_basic           "closed site";
            auth_basic_user_file htpasswd;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

Best Answer

Change listen 0.0.0.0:80; to listen *:80;.

REF: http://nginx.org/en/docs/http/ngx_http_core_module.html#listen