Multiple https website with IPv6
Kurogane
nginx-forum at forum.nginx.org
Tue Jan 2 06:40:20 UTC 2018
I am using nginx with multiples https with a single IPv4 and dedicated IPv6
for each domain.
The problem i'm having is i'm unable to redirect non www to www without
conflicting with the vhosts.
Here my setup
[b]Default[/b]
[code]
server {
listen 80 default_server;
listen [::2]:80 default_server;
server_name localhost;
}
[/code]
[b]domain[/b]
[code]
server {
listen 80;
listen [::2]:80;
server_name domain.com www.domain.com;
return 301 https://www.domain.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::2]:443 ssl http2;
server_name domain.com;
return 301 https://www.$server_name$request_uri;
}
server {
listen 443 default_server ssl http2;
listen [::2]:443 default_server ssl http2;
server_name www.domain.com;
}
[/code]
[b]domain 2[/b]
[code]
server {
listen 80;
listen [::3]:80;
server_name domain2.com www.domain2.com;
return 301 https://www.domain2.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::3]:443 ssl http2;
server_name domain2.com;
return 301 https://www.$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::3]:443 default_server ssl http2;
server_name www.domain2.com;
}
[/code]
So here's the problem
IPv4
https://www.domain.com ✔
https://domain.com ✔
http://www.domain.com ✔
http://domain.com ✔
https://www.domain2.com ✔
https://domain2.com ✗(NET::ERR_CERT_COMMON_NAME_INVALID - domain.com)
http://www.domain2.com ✔
http://domain2.com ✔
IPv6
https://www.domain.com ✔
https://domain.com ✔
http://www.domain.com ✔
http://domain.com ✔
https://www.domain2.com ✔
https://domain2.com ✔
http://www.domain2.com ✔
http://domain2.com ✔
In IPv4 domain (https://domain2.com) the certificate of domain.com is
served.
What's wrong with my config? If work on IPv6 why not in IPv4 is in same
config block?
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,277962,277962#msg-277962
More information about the nginx
mailing list