Apache VirtualHost with SSL Not Found
Solved. The problem is ServerName
at the head of httpd.conf
.
It should be removed if the main domain is defined as VirtualHost
.
Related videos on Youtube
Ap Tsi
Software and Telecommunication Engineer. Love learning from anyone.
Updated on September 18, 2022Comments
-
Ap Tsi over 1 year
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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 tohttps://www.example.com
, I getThe 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 theVirtualHost
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?
-
Jenny D almost 10 yearsWhat does your apache log say?
-
Ap Tsi almost 10 yearsin ssl_error_log "File does not exist: /etc/httpd/htdocs"
-
Jenny D almost 10 yearsThere'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 almost 10 yearsI 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".)
-
Ap Tsi almost 10 yearsWell, if I do not delete the ServerName outside the VirtualHost blocks, the problem arises.
-
fuero over 7 yearsNothing in this question mentions Let's Encrypt or trouble accessing said folders.