Quantcast

server listen directive for IPV4 and IPV6

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

server listen directive for IPV4 and IPV6

purvez
There is a lot of confusion in the answers I fount about it.

When I installed nginx first, it was the debian jessie version 1.6.2 and the
configuration to listen to both ipv4 and ipv6 was

#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

Now I use nginx 1.11.10 and the example configuration file only has one
line:
listen       80;


Should I update my configuration?  I might be wrong but I did not see ipv6
requests for a long while.

Last time I changed the listen directive following some recommendation found
on the web, I ended up with servers not listening to anything!

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

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: server listen directive for IPV4 and IPV6

Maxim Dounin
Hello!

On Wed, Mar 15, 2017 at 11:48:11PM -0400, shiz wrote:

> There is a lot of confusion in the answers I fount about it.
>
> When I installed nginx first, it was the debian jessie version 1.6.2 and the
> configuration to listen to both ipv4 and ipv6 was
>
> #server {
> #       listen 80;
> #       listen [::]:80;
> #
> #       server_name example.com;
> #
> #       root /var/www/example.com;
> #       index index.html;
> #
> #       location / {
> #               try_files $uri $uri/ =404;
> #       }
> #}
>
> Now I use nginx 1.11.10 and the example configuration file only has one
> line:
> listen       80;
>
>
> Should I update my configuration?  I might be wrong but I did not see ipv6
> requests for a long while.

If you want nginx to listen on both IPv4 and IPv6, you have to use
both

    listen 80;

and

    listen [::]:80;

in your configuration.

With nginx running, you can use "netstat -nlt" or "ss -nlt" to
find out which listening sockets are in fact open on your system.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: server listen directive for IPV4 and IPV6

purvez
Excellent.  Very grateful for the clarification!

Maxim Dounin Wrote:
-------------------------------------------------------

>
> If you want nginx to listen on both IPv4 and IPv6, you have to use
> both
>
>     listen 80;
>
> and
>
>     listen [::]:80;
>
> in your configuration.
>
> With nginx running, you can use "netstat -nlt" or "ss -nlt" to
> find out which listening sockets are in fact open on your system.
>
> --
> Maxim Dounin
> http://nginx.org/
> _______________________________________________
> nginx mailing list
> [hidden email]
> http://mailman.nginx.org/mailman/listinfo/nginx

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,272973,272980#msg-272980

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Loading...