1

I have an issue with two sites that are running on the same IP address. One as a virtual host. The issue is one of the sites loads correctly if you use the non-www address mountainx.com but if you go to the www address www.mountainx.com it tries to load the certificate for the other site givelocalguide.org.

I worked around this temporarily by adding a Redirect to givelocalguide.org that redirects back to mountainx.com but now I need to develop givelocalguide.org so have to take off the redirect. Why is the www version of www.mountainx.com loading an incorrect certificate? What is the relationship of these two sites? Why wouldn't it load the first site in the alphabetical list on that server?

Any help would be greatly appreciated.

<VirtualHost *:80>
       ServerAdmin     webmaster@example.com
       ServerName      example2.com
       ServerAlias     www.example2.com
       DocumentRoot    /srv/www/example2.com/public_html/
       ErrorLog        ${APACHE_LOG_DIR}/example2.com_error.log
       CustomLog       ${APACHE_LOG_DIR}/example2.com_access.log combined
</VirtualHost>

<VirtualHost 199.241.186.58:443>
       SSLEngine On
       SSLProtocol all -SSLv2 -SSLv3
       SSLCertificateFile      /etc/apache2/ssl/342rwqr424.crt
       SSLCertificateKeyFile   /etc/apache2/ssl/example2.com.key
       SSLCACertificateFile    /etc/apache2/ssl/gd_bundle-g2-g1.crt

       ServerAdmin     webmaster@example.com
       ServerName      example2.com
       DocumentRoot    /srv/www/example2.com/public_html/
       ErrorLog        ${APACHE_LOG_DIR}/example2.com_error_ssl.log
       CustomLog       ${APACHE_LOG_DIR}/example2.com_access_ssl.log combined
</VirtualHost>


root@hiphop:/etc/apache2/sites-available# vi example.com

<VirtualHost *:80>
       ServerAdmin     webmaster@example.com
       ServerName      example.com
       ServerAlias     www.example.com
       ServerAlias     hammer.example.com
       DocumentRoot    /srv/www/example.com/public_html/
       ErrorLog        ${APACHE_LOG_DIR}/example.com_error.log
       CustomLog       ${APACHE_LOG_DIR}/example.com_access.log combined
</VirtualHost>

<VirtualHost 199.241.186.58:443>
       SSLEngine On
       SSLProtocol all -SSLv2 -SSLv3
       SSLCertificateFile      /etc/apache2/ssl/342ew4233.crt
       SSLCertificateKeyFile   /etc/apache2/ssl/example.com.key
       SSLCACertificateFile    /etc/apache2/ssl/gd_bundle-g2-g1.crt

       ServerAdmin     webmaster@example.com
       ServerName      example.com
       DocumentRoot    /srv/www/example.com/public_html/
       ErrorLog        ${APACHE_LOG_DIR}/example.com_error_ssl.log
       CustomLog       ${APACHE_LOG_DIR}/example.com_access_ssl.log combined
</VirtualHost>
ceejayoz
  • 32,469
  • 7
  • 81
  • 105

1 Answers1

2

If your configuration posted is accurate it appears that you are missing:

ServerAlias www.example.org

In your virtual host config. Assuming your mountainx.com certificate is setup for mountainx.com and www.mountainx.com at godaddy you should be good to go.

More details: https://httpd.apache.org/docs/2.4/mod/core.html#serveralias

Daniel Widrick
  • 3,418
  • 2
  • 12
  • 26