why is nginx binding to when I specify explicit IPs to listen on?

middleforkgis nginx-forum at nginx.us
Tue Jan 22 22:15:54 UTC 2013

I'm having a difficult time understanding why I'm unable to limit the IP
address to which nginx binds.

nginx                          1.2.6-1
Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.35-2 x86_64 GNU/Linux

root at skokomish:/etc/nginx# netstat -pant |grep nginx
tcp        0      0    *               LISTEN  
tcp        0      0*               LISTEN  

shows that it is binding on port 80 of all IP addresses.
Yet each of my hosts is explicitly listening on a single IP address:

root at skokomish:/etc/nginx/sites-available# more default
{ listen; }
root at skokomish:/etc/nginx/sites-available# more example
    server_name example.com www.example.com;
    access_log /var/log/ngnix/example.log;
    error_log /var/log/nginx/example.error.log;

   location /site {
   	alias /data/www/content/site/example;
   location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 10;
        proxy_read_timeout 10;

There is no 'listen' statement in nginx.conf itself:
root at skokomish:/etc/nginx# grep listen nginx.conf
#		listen     localhost:110;
#		listen     localhost:143;
Grepping for 'listen' shows:

root at skokomish:/etc/nginx# for i in `find .`; do grep listen $i;
grep: .: Is a directory
grep: ./sites-enabled: Is a directory
grep: ./conf.d: Is a directory
grep: ./sites-available: Is a directory
{ listen; }
#		listen     localhost:110;
#		listen     localhost:143;
root at skokomish:/etc/nginx# ls conf.d
root at skokomish:/etc/nginx# 

Thanks in advance.

-Steve W.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,235428,235428#msg-235428

More information about the nginx mailing list