Listen and IPV6 behaviour ?

Jérôme Loyet jerome at loyet.net
Mon Nov 9 21:17:24 MSK 2009


Hi all,

How to use the nginx listen diective to listen on all interface (ipv4
and ipv6) and on port 80 ?

I thought "listen [::]:80;" would be enought but it seems that I have
to use both "listen 80;" and "listen [::]:80;"

Is it the normal behaviour or a bug ?

++ Jerome

OS: OpenBSD 4.5 and linux 2.6.28
Im' using nginx 0.8.22
I've enable ipv6 support at compile time with --with-ipv6
I use the default nginx conf file (just the port has been changed to 81)
My server is fully ipv6 compliant.

If I start nginx, it listens on ipv4 only :
listen 81;

root at wild:~/nginx-0.8.22# lsof -i :81
COMMAND   PID   USER   FD   TYPE   DEVICE SIZE NODE NAME
nginx   18224   root    6u  IPv6 26577575       TCP *:81 (LISTEN)
nginx   18225 nobody    6u  IPv6 26577575       TCP *:81 (LISTEN)

If I changed the listen directive to:
listen [::]:81;

root at wild:~/nginx-0.8.22# lsof -i :81
COMMAND   PID   USER   FD   TYPE   DEVICE SIZE NODE NAME
nginx   18224   root    6u  IPv6 26577575       TCP *:81 (LISTEN)
nginx   18361 nobody    6u  IPv6 26577575       TCP *:81 (LISTEN)

If I use both:
listen [::]:81;
listen 81;

root at raptor> lsof -i :80
COMMAND   PID   USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
nginx   23184 nobody   10u  IPv6 0xd639be40    TCP *:81 (LISTEN)
nginx   23184 nobody   11u  IPv4 0xd639b990    TCP *:81 (LISTEN)
nginx   23235   root   10u  IPv6 0xd639be40       TCP *:81 (LISTEN)
nginx   23235   root   11u  IPv4 0xd639b990       TCP *:81 (LISTEN)





More information about the nginx mailing list