So, today I decided to make LowEndGuide IPv6 enabled and spent most of my morning troubleshooting why my vps didn’t show my IPv6 addresses. Well, that’s not what this post is about. Now I will show you how to enable it for NGINX.
If you, like me installed nginx from the package, you will most likely have ipv6 enabled, but if you have complied it yourself, that is not always the case.
You can check it by running “nginx -V
“:
if you have this “--with-ipv6"
option in configure arguments, you are good to go.
[precode]
# nginx -V
nginx version: nginx/1.2.7
TLS SNI support enabled
configure arguments: –with-ipv6
[/precode]
(the configure arguments part above is incomplete, it should contain alot more. I’ve shortened it for readability).
After you’ve check that your nginx installation has IPv6 support, you need to enable it by changing the “listen"
directives in your configuration file.
[alert style=”green”]If you, like me uses MINSTALL to configure the installation, you must make sure to update ALL configuration files before continuing. NginX will not load properly if not. [/alert]
If your server binds to all interfaces/IPs on the default port, you already have listen 80
in your config-file.
To tell nginx to listen on both IPv4 and IPv6 find this line:
[precode]
listen 80;
[/precode]
and change it to:
[precode]
listen [::]:80;
[/precode]
If you for some reason, only want to listen on your IPv6 and disable IPv4, use the ipv6only=on
parameter:
[precode]
listen [::]:80 ipv6only=on;
[/precode]
For configurations that needs to bind to specific ip address you could use similar notation:
[precode]listen [2001:0db8:85a3:0042:1000:8a2e:0370:7334]:80 ipv6only=on;[/precode]
After updating your config-files and tested them (/etc/init.d/nginx configtest ) you need to restart (a reload is not enough) the nginx process.
If you see something like this:
[precode]
Restarting nginx: nginx.
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80failed (98: Address already in use)
nginx: [emerg] still could not bind()
[/precode]
You probably forgot to change the “listen” directive in one or more of your config-files. (Your site is now not working, so get to it and find the problem).
If ngingx restarts without error messsages, check your system port bindings to make sure it works as expected:
[precode]# netstat -nlp | grep nginx
tcp 0 0 :::80 :::* LISTEN 23817/nginx
tcp 0 0 :::443 :::* LISTEN 23817/nginx
[/precode]
This is it, now you can add AAAA records to your domain name and test it here.
1 comment for “Enabling IPv6 Support in nginx”