Forum: NGINX bug in listen in 0.6.{32,35}?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2974d09ac2541e892966b762aad84943?d=identicon&s=25 mikew (Guest)
on 2009-04-15 19:02
(Received via mailing list)
Hey All,

We're extremely happily using nginx 0.5.blah for much hosting.
0.5.x isn't broke, so we have no plans to "fix" it in the forseable
future. However, we have a good use for gzip_static, so have to move to
0.6.x for some servers.

I'm having trouble converting our config style from 0.5.x to 0.6.x,
"listen" isn't working how it used to, or how the documentation says it
should.
Each server has it's own IP address, and a series of extra IP addresses
for serving content. To save serious headaches we need to use the same
config on multiple machines, in different data centres.
Previously a config like this worked as expected:

server {
listen *:80 default bind;
server_name hostname1.dc1.blah hostname2.dc1.blah hostname.dc2.blah
}
server {
listen 192.168.36.20:80;
listen 192.168.136.20:80;
server_name www.blah.com;
}
server {
listen 192.168.36.20:80;
listen 192.168.136.20:80;
server_name www.foo.com;
}

nginx would bind to *:80 and not complain that it doesn't have any of
the other IPs.
With nginx 0.6.35 (and 0.6.32) that configuration fails the test, and
logs this:

2009/04/15 17:12:19  4767#0: bind() to 192.168.36.80:80 failed (99:
Cannot assign requested address)

If I take out listen directives for IPs this machine does not have, the
config test passes, but it still won't start, with logs like this:

2009/04/15 17:02:20  4702#0: bind() to 127.0.0.1:80 failed (98: Address
already in use)
2009/04/15 17:02:20  4702#0: bind() to 192.168.136.80:80 failed (98:
Address already in use)
2009/04/15 17:02:20  4702#0: try again to bind() after 500ms
2009/04/15 17:02:20  4702#0: bind() to 127.0.0.1:80 failed (98: Address
already in use)
2009/04/15 17:02:20  4702#0: bind() to 192.168.136.80:80 failed (98:
Address already in use)
2009/04/15 17:02:20  4702#0: try again to bind() after 500ms
2009/04/15 17:02:20  4702#0: still could not bind()


Am I missing something, or should this not have worked before (in which
case, what should I be doing?), or have I found a bug?

Many thanks
Mike

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1079,1079#msg-1079
2974d09ac2541e892966b762aad84943?d=identicon&s=25 SSSlippy (Guest)
on 2009-04-15 20:38
(Received via mailing list)
If I remember correctly u can not have more then one server config with
the same port in the same config file. Give each URL it's own file using
vhosts. There is an example in the wiki.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1079,1083#msg-1083
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-04-15 20:49
(Received via mailing list)
On Wed, Apr 15, 2009 at 12:53:57PM -0400, mikew wrote:

> listen *:80 default bind;
> server_name www.foo.com;
> 2009/04/15 17:02:20  4702#0: bind() to 192.168.136.80:80 failed (98: Address already in 
use)
> 2009/04/15 17:02:20  4702#0: try again to bind() after 500ms
> 2009/04/15 17:02:20  4702#0: bind() to 127.0.0.1:80 failed (98: Address already in use)
> 2009/04/15 17:02:20  4702#0: bind() to 192.168.136.80:80 failed (98: Address already in 
use)
> 2009/04/15 17:02:20  4702#0: try again to bind() after 500ms
> 2009/04/15 17:02:20  4702#0: still could not bind()
>
>
> Am I missing something, or should this not have worked before (in which case, what 
should I be doing?), or have I found a bug?

I can not reproduce these errors on 0.6.36 with above configuration:
in my test nginx binds to the *:80 only.
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-04-15 20:50
(Received via mailing list)
On Wed, Apr 15, 2009 at 02:31:44PM -0400, SSSlippy wrote:

> If I remember correctly u can not have more then one server config with the same port in 
the same config file. Give each URL it's own file using vhosts. There is an example in the 
wiki.

No, this is a valid configuration.
8389b1baedd7e2286b1414aed0aa44ad?d=identicon&s=25 Michael Ching (Guest)
on 2009-04-15 20:58
(Received via mailing list)
> nginx would bind to *:80 and not complain that it doesn't have any of the other IPs.
> With nginx 0.6.35 (and 0.6.32) that configuration fails the test, and logs this:

Your error message is saying that it is having a problem binding to port
80 on 127.0.0.1 and 192.168.136.80, not the other IPs listed.  Do you
have something else already listening on the port?  'netstat -lnpt |
grep 80' or similar could show you what has the port bound.
2974d09ac2541e892966b762aad84943?d=identicon&s=25 mikew (Guest)
on 2009-04-15 20:58
(Received via mailing list)
Sorry, I missed a server set to listen on "127.0.0.1" included by
unwanted file caught in a glob.
listen does work how the documentation says it does!

Mike

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1079,1088#msg-1088
This topic is locked and can not be replied to.