0

I setup 3 virtual hosts on port 80. Everything is fine. Now I would setup the SSL version of these virtual hosts. All works except the main DocumentRoot.

Listen 80 
ServerName www.mydomain.com
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /home/someone/www/work
    ServerName work.example.com
    <Directory /home/someone/www/work>
    Options +FollowSymLinks
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>

</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /home/someone/www
    ServerName www.example.com
    <Directory /home/someone/www>
    Options +FollowSymlinks
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin webmaster@example.com
    DocumentRoot /home/someone/www/work
    ServerName work.example.com
    SSLEngine on
    SSLCertificateFile /home/someone/ssl-certs-keys/c1.crt
    SSLCertificateKeyFile /home/someone/ssl-certs-keys/c1.key
    SSLCertificateChainFile /home/someone/ssl-certs-keys/c1.i.crt

    <Directory /home/someone/www/work>
    Options +FollowSymLinks
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>

</VirtualHost>

<VirtualHost *:443>
    ServerAdmin webmaster@example.com
    DocumentRoot /home/someone/www
    ServerName www.example.com
    SSLEngine on
    SSLCertificateFile /home/someone/ssl-certs-keys/c1.crt
    SSLCertificateKeyFile /home/someone/ssl-certs-keys/c1.key
    SSLCertificateChainFile /home/someone/ssl-certs-keys/c1.i.crt
    <Directory /home/someone/www>
    Options +FollowSymlinks
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>
</VirtualHost>

Now, no problem if I connect to www.example.com, work.example.com, https://work.example.com. The only problem is that when I connect to https://www.example.com, I get The requested URL / was not found on this server".

If I add somewhere in httpd.conf DocumentRoot /home/someone/www the pages there are loaded... Why, for 443, I have to add DocumentRoot, and why the VirtualHost for the main domain is not read.

[EDIT]

As for a comment, if I type httpd -S

VirtualHost configuration:

wildcard NameVirtualHosts and _default_ servers:
*:443                  is a NameVirtualHost
         default server www.mydomain.com (/etc/httpd/conf.d/ssl.conf:74)
         port 443 namevhost www.mydomain.com (/etc/httpd/conf.d/ssl.conf:74)
         port 443 namevhost work.mydomain.com (/etc/httpd/conf/httpd.conf:1074)

Why the default server points to ssl.conf and not httpd.conf?

  • What does your apache log say? – Jenny D Jun 26 '14 at 8:22
  • in ssl_error_log "File does not exist: /etc/httpd/htdocs" – giuseppe Jun 26 '14 at 8:59
  • There's something wrong with your config but I can't find it from what you've posted here. There might be a typo that's hidden by your obfuscation, for instance. You can try doing httpd -S to show the virtualhost settings and include them into the question. – Jenny D Jun 26 '14 at 9:38
1

Solved. The problem is ServerName at the head of httpd.conf. It should be removed if the main domain is defined as VirtualHost.

  • I would use the name of the server instead, but that's largely a matter of taste. (For instance, my personal web server is called "sameen" which I use as the main ServerName, and has a virtual host with "www.example.com".) – Jenny D Jun 26 '14 at 11:39
  • Well, if I do not delete the ServerName outside the VirtualHost blocks, the problem arises. – giuseppe Jun 26 '14 at 12:43
-1

I may have the solution to your problem. It may be due to your folder permission. Simple using your FTP client go to /etc/letsencrpyt make sure that every of your folders permissions are set to 0755 (do so by right clicking and select file permission).

  • Nothing in this question mentions Let's Encrypt or trouble accessing said folders. – fuero Dec 14 '16 at 9:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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