0

I am setting up SSL on my Apache/2.4.6 RHEL server. In httpd.conf, have VirtualHosts as shown below...

<VirtualHost *:80>
    ServerName foo.bar
    Redirect permanent / https://foo.bar
</VirtualHost>


<VirtualHost *:443>
    DocumentRoot /path/to/file

    ServerName foo.bar

    SSLEngine on
    SSLCertificateFile /path/to/file
    SSLCertificateKeyFile /path/to/file
    SSLCertificateChainFile /path/to/file

</VirtualHost>

When I comment out DocumentRoot in httpd.conf outside of the VirtualHosts, the web browser returns error 404 The requested URL / was not found on this server.

Do I need to have a DocumentRoot outside of VirtualHost *:443? If not, what is going on when I comment it out?

2
  • Why would you want to remove that statement from the 443 virtualhost? It's there for a reason: to tell Apache where to find the documents it needs to serve. If you remove it, it will most likely fall back to a globally defined path or possibly a default, but it most likely won't work.
    – Teun Vink
    Jan 20, 2016 at 7:04
  • Hi, I agree. I do not want to remove DocumentRoot from VirtualHost 443, but when I do not have a DocumentRoot defined outside of the virtualhosts above the error occurs
    – Jon Snow
    Jan 21, 2016 at 3:54

2 Answers 2

0

You will have in some apache config a DocumentRoot defined, which is likely not accessible by the server, you can check this by issuing for RHEL flavours:

 /usr/sbin/httpd -S

and Debian

/usr/sbin/apache2ctl -S 

It should contain a variable:

Main DocumentRoot: "/var/www/html"

You can either adjust this or set one in the virtual host section (I would prefer this one, being set to the same of the SSL vhost).

0

Turns out I had ssl.conf set up separately and incorrectly. Fixed the ssl.conf and removed the VirtualHost for 443 from httpd.conf, and it works like a charm!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .