IPv6 is the latest internet protocol that improves website speed and performance, and also provides better security. However, it is not enabled, by default, in NGINX web server. Here’s how to enable IPv6 in NGINX.
How to Enable IPv6 in NGINX
Here are the steps to enable IPv6 in NGINX
1. Open NGINX config file
Open NGINX config file in a text editor.
You will find it at one of the following locations, depending on the type of installation
/etc/nginx/conf.d/default.conf /etc/nginx/sites-enabled/default /etc/nginx/nginx.conf
$ sudo vim /etc/nginx/nginx.conf
2. Enable IPv6
You will see the following line
listen [::]:80 default_server;
If not, then update the listen directive in server block as shown above.
However, if you have multiple virtual hosts, then update the line to
listen [2400:6180:0:d0::1f33:d001]:80 default_server;
3. Reload NGINX web server
Test the config file to ensure there are no errors.
$ sudo nginx -t
If you get no error message, reload NGINX server to apply changes.
$ sudo service nginx reload
4. Test IPv6
To test if your server port listens to IPv6, just run the netstat command in terminal
# netstat -anlp |grep 80 tcp 0 0 22.214.171.124:80 0.0.0.0:* LISTEN 23047/httpd tcp6 0 0 2400:6180:0:d0::1f33:80 :::* LISTEN 23047/httpd
That’s it! Now NGINX will serve through IPv6 protocol and you should see better website performance.