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?
Best Answer
Solved. The problem is
ServerName
at the head ofhttpd.conf
. It should be removed if the main domain is defined asVirtualHost
.