I have a really weird problem. I own multiple domains let's say example.com, example.pl, example.at, etc. My main domain is example.com, all the rest should be (and mostly are) redirected to example.com for which I own certificate (only for this one). Now what is strange is that if I go to whichever of my domains, doesn't matter if I use www or not, all these domains get properly redirected with code 301 to https://example.com. All except one - www.example.com - this one always gets 307 and ERR_CERT_COMMON_NAME_INVALID. I'm totally lost. Have anyone experienced something like this?
Here is my nginx sites-available config:
server {
listen 80;
server_name example.com;
location / {
return 301 https://example.com$request_uri;
}
}
server {
listen 443 ssl default_server;
server_name example.com;
include /etc/nginx/headers/headers.conf;
include /etc/nginx/ssl-options/options-ssl-nginx.conf;
ssl_dhparam /etc/nginx/ssl-options/ssl-dhparams.pem;
access_log /var/log/nginx/data-access.log combined;
if ($http_host = www.example.com){
return 303 https://example.com$request_uri;
}
if ($http_host != example.com){
return 303 https://example.com$request_uri;
}
location / {
root /usr/share/nginx/html;
try_files $uri /blog-build.html;
}
}