2

Apache is ignoring the DocumentRoot setting in my VirtualHost configuration.

The site loads the correct DocumentRoot via http on port 80 but when accessed over https on port 443 it loads the apache's default DocumentRoot at /var/www/html instead of var/www/mysite.

The SSL certificate does load correctly, it's just the DocumentRoot that is being ignored.

I'm running Apache/2.4.6 on CentOS.

Configuration as follows:

# /etc/httpd/vhost.d/mysite.mylabserver.com_httpd.conf

<VirtualHost *:80>
        ServerName mysite.labserver.com
        ServerAlias mysite

        DocumentRoot /var/www/mysite
</VirtualHost>

<VirtualHost *:443>
        ServerName mysite.mylabserver.com
        ServerAlias mysite

        DocumentRoot /var/www/mysite

        SSLEngine on
        SSLCertificateFile /etc/httpd/ssl-certs/apache.crt
        SSLCertificateKeyFile /etc/httpd/ssl-certs/apache.key
</VirtualHost>
  • 1
    try with <VirtualHost default:443> insted of *:443 – Noel Carcases Jan 29 '17 at 13:51
  • Same outcome using default:443 – Alxs Jan 29 '17 at 14:00
  • 1
    there is a config file on /etc/httpd/conf.d called ssl.conf (or something similar) holding on the default ssl config. You have three options then... edit that file, remove that file (not recommended) or use a named virtual host <VirtualHost your_ip_address_or_host_name:443>. Let me know if that helps and I will post it as an answer – Noel Carcases Jan 29 '17 at 14:20
  • Cheers @NoelCarcases, I will try. – Alxs Jan 29 '17 at 14:24
  • Thanks @NoelCarcases, the ssl.conf was conflicting with my config. I renamed it ssl.template and only had to copy across the Listen 443 https to my config (outside the VirtualHost). Please include in answer. :) – Alxs Jan 29 '17 at 14:51
2

there is a config file on

/etc/httpd/conf.d called ssl.conf (or something similar)

holding on the default ssl config.

You have three options then...

  1. edit that file
  2. remove that file (not recommended)
  3. use a named virtual host .

Please keen in mind to copy the Listen 443 to your file.

Let me know if that helps

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.