How to: Nginx dual stack and multiple domains

In this how to i’m going to show you how to setup Nginx dual stack when running multiple websites.

Change directory to: /etc/nginx/sites-enabled/

Then in one of your config files, inside a server bracket replace:

listen 80;

with:

listen 80;

listen [::]:80 ipv6only=on;

Then in all other files replace:

listen 80;

with:

listen 80;

listen [::]:80;

You will have to do the ipv6only=on once per port.

Then it should look like this:

/etc/nginx/sites-enabled/site1:


server {
listen 443;
listen [::]:443 ipv6only=on;
server_name site1.com;

...

}
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name www.site1.com;
...
}

 

/etc/nginx/sites-enabled/site2:


server {
listen 443;
listen [::]:443;
server_name site2.com;

...

}


server {
listen 80;
listen [::]:80;
server_name www.site2.com;
...
}

Lasse Hyldahl Jensen on EmailLasse Hyldahl Jensen on GithubLasse Hyldahl Jensen on GoogleLasse Hyldahl Jensen on InstagramLasse Hyldahl Jensen on LinkedinLasse Hyldahl Jensen on Twitter
Lasse Hyldahl Jensen

Leave a comment

Leave a Reply