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 “
if you have this “
--with-ipv6" option in configure arguments, you are good to go.
# nginx -V nginx version: nginx/1.2.7 TLS SNI support enabled configure arguments: –with-ipv6
(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.
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.
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:
and change it to:
If you for some reason, only want to listen on your IPv6 and disable IPv4, use the
listen [::]:80 ipv6only=on;
For configurations that needs to bind to specific ip address you could use similar notation:
listen [2001:0db8:85a3:0042:1000:8a2e:0370:7334]:80 ipv6only=on;
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:
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()
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:
# netstat -nlp | grep nginx tcp 0 0 :::80 :::* LISTEN 23817/nginx tcp 0 0 :::443 :::* LISTEN 23817/nginx
This is it, now you can add AAAA records to your domain name and test it here.