1

I have the VirtualHost directives in the webserver config files in the following format:

<VirtualHost *:443>
  ServerName example.com

Entering https://example.com to the browser renders the site correctly, traffic is TLS encrypted. As soon as I rewrite it to

<VirtualHost example.com:443>

Firing a GET request to the domain on port 443 results in an SSL error, namely NET::ERR_CERT_COMMON_NAME_INVALID in Chrome, which says, that the webserver provided a certificate that is valid for example.net (this other domain is still hosted on my server).

If I look into the cert (openssl x509 -in cert.pem -text), I get that it's issued for

Subject: CN=example.com

The path to the cert is correctly configured.

Additional info: Both domains resolve to the same 127.0.0.1 in the hosts file, NameVirtualHost is not set, and there is a proxy in front of the webserver, which hopefully has nothing to do with this issue.

2

Argument to the VirtualHost directive must match a defined NameVirtualHost directive.

You can't use domain.com in the VirtualHost directive if you don't have NameVirtualHost domain.com defined in config, which is something not commonly used, * or IP is generally used for NameVirtualHost.

Since this VirtualHost is not valid, it loads the first or default VirtualHost it exists on that IP for port 443, which is anotherdomain.com whose SSL you are being served.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.