Nginx 0.8.4 Trying to bind on port 80?

My configuration is:
Apache listening on port 80, Iptables redirecting port 80 to port 8080,
Nginx listening on port 8080.

I have been using Nginx with the same configuration for several months
(0.7.x and 0.8.x):
–conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid
–lock-path=/var/lock/nginx.lock
–http-log-path=/var/log/nginx/access.log
–http-client-body-temp-path=/dev/shm/client
–http-proxy-temp-path=/dev/shm/proxy
–http-fastcgi-temp-path=/dev/shm/fastcgi --with-debug
–with-http_stub_status_module --with-http_flv_module
–with-http_ssl_module --with-http_dav_module
–with-http_secure_link_module

And until latest version i had no issue starting Nginx, yet today after
compiling 0.8.4 i got the following error:

the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
Starting nginx: : bind() to 0.0.0.0:80 failed (98: Address already in
use )
: bind() to 0.0.0.0:80 failed (98: Address already in use)
: bind() to 0.0.0.0:80 failed (98: Address already in use)
: bind() to 0.0.0.0:80 failed (98: Address already in use)
: bind() to 0.0.0.0:80 failed (98: Address already in use)
: still could not bind()
nginx.

Any idea of what is going wrong ?

Posted at Nginx Forum:

lsof -i tcp:80lsof -i tcp:8080

Maybe i was not very clear, but the same configuration worked up to
0.8.3 included, upgrading to 0.8.4 fail due to bind issue, downgrading
to 0.8.3 works fine with no change in configuration.

As usual apache2 listen on port 80
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
apache2 11963 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 11964 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 11965 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 18919 root 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 27514 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 27515 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 27520 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 27521 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 27523 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 27524 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 27596 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 31555 www-data 4u IPv6 1976954 TCP *:www (LISTEN)
apache2 32109 www-data 4u IPv6 1976954 TCP *:www (LISTEN)

And nginx listen on port 8080 (at least when running 0.8.3)

The real issue is that the 0.8.4 is trying to bind on port 80 while the
conf files are telling it to bind to port 8080. The configuration files
have not changed for months, it’s the first time i encounter the issue.

Posted at Nginx Forum:

Yeah, okay, I figured that.
So you’re proxying apache to nginx then? That’s the wrong way to go! :slight_smile:

If I wasn’t so lazy I would try 0.8.x on a box and see if I can
reproduce.
Either way though I wouldn’t be able to fix it. Maxim or Igor would be
able
to locate it pretty quick I’m sure. IIRC Igor might be on vacation I
think
too.

No !!! As i wrote on the first page the setup is as follow:
IPTABLES roots external access to port 80 to port 8080 which is NGinx
Listening Port.
From then on either NGinx serves all the pages or proxy them to Apache
depending on which Vhost is considered. So it’s really Nginx proxying to
Apache not the other way round. With this setup i can simply remove
Nginx by just erasing the IPTABLES rule.

This setup has not been changed for months, and it works for every Nginx
iteration up to 0.8.3, but fail with bind error on the 0.8.4 release.

Posted at Nginx Forum:

I thought you had said iptables originally. Except according to your
lsof output port 80 is in use by apache2…

At least that’s what I gandered unless that was 8080 and it’s labeled
as www. I’m on my phone right now so it’s hard to go back and forth
but check that quick (if I’m not wrong about 8080 being labeled www as
well)

Sent from my iPhone

Hi Jim,

Ok i will double check, maybe the options got mangled when i copied them
back for compilation.

olivier.

Posted at Nginx Forum:

An other process is using the same address, chances are it’s apache, in
that
case :
sudo /etc/init.d/apache2 stop

may correct the problem.

Posted at Nginx Forum:

olefebvre Wrote:

This setup has not been changed for months, and it
works for every Nginx iteration up to 0.8.3, but
fail with bind error on the 0.8.4 release.

Are you certain that your nginx.conf has not been overwritten or the
path changed with your latest configuration?

On a Linux test server I set Apache to listen on 80. I compiled
nginx-0.8.4 from source with the following very basic configure command:

nginx -V

nginx version: nginx/0.8.4
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-44)
configure arguments: --pid-path=/usr/local/nginx/logs/nginx.pid
–sbin-path=/usr/local/sbin/nginx --with-http_stub_status_module
–user=nginx --group=nginx

I used the default nginx.conf with the exception that I changed the
“listen” directive from

listen 80;

to

listen 8080;

I started Apache and it grabbed 80:

service httpd start

Starting httpd: [ OK ]

lsof -i tcp:80

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
httpd 13767 root 4u IPv6 84950 TCP *:http (LISTEN)
httpd 13769 apache 4u IPv6 84950 TCP *:http (LISTEN)
httpd 13770 apache 4u IPv6 84950 TCP *:http (LISTEN)
httpd 13771 apache 4u IPv6 84950 TCP *:http (LISTEN)
httpd 13772 apache 4u IPv6 84950 TCP *:http (LISTEN)
httpd 13773 apache 4u IPv6 84950 TCP *:http (LISTEN)
httpd 13774 apache 4u IPv6 84950 TCP *:http (LISTEN)
httpd 13775 apache 4u IPv6 84950 TCP *:http (LISTEN)
httpd 13776 apache 4u IPv6 84950 TCP *:http (LISTEN)

I then started nginx and it grabbed 8080:

/usr/local/sbin/nginx

lsof -i tcp:8080

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
nginx 13779 root 6u IPv4 85204 TCP *:webcache (LISTEN)
nginx 13780 nginx 6u IPv4 85204 TCP *:webcache (LISTEN)

I then edited nginx.conf to have nginx listen on 80 and attempted a
reload. It failed. Output from error log:

2009/06/28 20:09:54 13787#0: signal process started
2009/06/28 20:09:54 13779#0: bind() to 0.0.0.0:80 failed (98: Address
already in use)
2009/06/28 20:09:54 13779#0: bind() to 0.0.0.0:80 failed (98: Address
already in use)
2009/06/28 20:09:54 13779#0: bind() to 0.0.0.0:80 failed (98: Address
already in use)
2009/06/28 20:09:54 13779#0: bind() to 0.0.0.0:80 failed (98: Address
already in use)
2009/06/28 20:09:54 13779#0: bind() to 0.0.0.0:80 failed (98: Address
already in use)
2009/06/28 20:09:54 13779#0: still could not bind()

The most logical conclusion is that with your latest compile the path to
nginx.conf was changed or nginx.conf was overwritten.

Please post the output of

nginx -V

(for both nginx-0.8.3 and nginx-0.8.4)

and the contents of nginx.conf file that is specified by each.

Posted at Nginx Forum: