0

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;
  }
}
Pepsko
  • 63
  • 6
  • The error comes from a mismatch between the domain name in the URL and what the certificate contains. This means that you have a certificate configured for this domain which does not cover the domain name from the URL. More details cannot be given because it is unknown what certificates you have, what domains these cover and how you have configured these. – Steffen Ullrich Sep 09 '21 at 06:05
  • The certificate covers only the example.com, but I don't get that error when I try go to example.at, example.pl, www.example.at etc.. only when I go to www.example.com. – Pepsko Sep 09 '21 at 10:33

0 Answers0