Enabling IPv6 connectivity in Nginx is very easy, providing you already have a valid IPv6 connection/IP on your server. You should normally already have a configuration as follows.
server {
listen 80;
server_name a.b.c;
}
First, verify that your nginx is configured for IPv6.
# nginx -V ... --with-ipv6 ...
Now, you can change your nginx configuration file to enable IPv6. To create server-block that listens on all available IPv6 IPs as well as IPv4, add this.
server {
listen :80;
listen [::]:80;
server_name a.b.c;
}
If you want a server-block that only listens on IPv6 and not IPv4, make use of the ipv6only flag.
server {
listen [::]:80 ipv6only=on;
server_name a.b.c;
}
Binding IPv6 on a single IP can also be done as such.
server {
listen [2a03:a800:2:1::1]:80 ipv6only=on;
server_name a.b.c;