I have two vhosts : one on domain.tld port 80, the other on sub.domain.tld port 443 with SSL on. I added a CNAME entry on my DNS server that redirects my sub subdomain to domain.tld..
Everything works as expected, but going to http://sub.domain.tld does the same as going to http://domain.tld, and https://domain.tld the same as https://sub.domain.tld. How can I prevent this ?
My configuration :
server {
listen *:443;
listen [::]:443;
server_name www.sub.domain.tld;
ssl on;
ssl_certifiate ...;
ssl_certifiate_key ...;
root /var/www/sub.domain.tld;
...
}
server {
listen *:80;
listen [::]:80;
server_name www.domain.tld;
root /var/www/domain.tld;
...
}