0

I have an apache config using a DV wildcard cert. The ssl.conf is configured to use the certificate for all server traffic.

My vhost conf file has two virtual hosts defined there. A production vhost and a dev vhost. The conf file contents are;

<VirtualHost *:443>
  ServerName www.example.com
  ServerAlias example.com
  ServerAdmin webmaster@example.com
  DocumentRoot /var/www/html/vhosts/prod_example_com/

  <Directory "/var/www/html/vhosts/prod_example_com">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>

  ErrorLog "/var/log/httpd/www.example.com-error_log"
  CustomLog "/var/log/httpd/www.example.com-access_log" common

  #   Enable/Disable SSL for this virtual host.
  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/comodo/STAR_example_com.crt
  SSLCertificateKeyFile /etc/pki/tls/certs/csr/www_example_com.key
  SSLCertificateChainFile /etc/pki/tls/certs/comodo/SectigoRSADomainValidationSecureServerCA.crt
</VirtualHost>


<VirtualHost *:443>
  ServerName dev.example.com
  ServerAdmin webmaster@example.com
  DocumentRoot "/var/www/html/vhosts/dev_example_com"

  <Directory "/var/www/html/vhosts/dev_example_com">
    AllowOverride All
    Require all granted
  </Directory>

  ErrorLog "/var/log/httpd/dev.example.com-error_log"
  CustomLog "/var/log/httpd/dev.example.com-access_log" common

  #   Enable/Disable SSL for this virtual host.
  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/comodo/STAR_example_com.crt
  SSLCertificateKeyFile /etc/pki/tls/certs/csr/www_example_com.key
  SSLCertificateChainFile /etc/pki/tls/certs/comodo/SectigoRSADomainValidationSecureServerCA.crt
</VirtualHost>

So, when I go to https://dev.example.com, it works great. However, when I try to go to https://www.example.com, it instead goes to the Apache server webroot of /var/www/html.

Have I overlooked something?

Thanks in advance to any help offered?

1
  • I'm beginning to ascertain that this issue has something to do with the <VirtualHost *:443> tag. If I change the dev vhost from <VirtualHost *:443> to <VirtualHost server_ip:443> (where server_ip = to my public IP for the host, then the dev site throws 404 errors. – Skittles Feb 4 '20 at 15:44
0

Restarting apache should give you hints in ssl_error_log, your first config file suggests you forgot the closing tag </VirtualHost>, althought apache should not even start in this case (syntax error).

1
  • Actually, the editor here cut it out. It's in my conf file. I just fixed it in the editor here. Thanks for calling that out though! – Skittles Feb 4 '20 at 16:22
0

I seemed to have found the issue. In my particular instance, the vhost.conf VirtualHost tags were change both to *:443, but what got everything back on track was commenting out ServerName www.example.com:443 from my httpd.conf and restarting Apache. I hope this helps someone else that may be suffering from this same issue.

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.