我在端口 80 上设置了 3 个虚拟主机。一切正常。现在我要设置这些虚拟主机的 SSL 版本。除主版本外,其他版本均能正常工作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>
现在,如果我连接到www.example.com
、work.example.com
、 ,就没有问题了https://work.example.com
。唯一的问题是,当我连接到 时https://www.example.com
,我得到的是The requested URL / was not found on this server
“。
如果我在 httpd.conf 中的某个位置添加 DocumentRoot /home/someone/www,那么就会加载那里的页面...为什么对于 443,我必须添加DocumentRoot
,以及为什么VirtualHost
主域的没有被读取。
[编辑]
至于评论,如果我输入 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)
为什么默认服务器指向 ssl.conf 而不是 httpd.conf?
答案1
已解决。问题出ServerName
在 的开头httpd.conf
。如果主域定义为VirtualHost
,则应将其删除。
答案2
我可能有办法解决你的问题。这可能是由于你的文件夹权限。只需使用你的 FTP 客户端转到 /etc/letsencrpyt,确保你的每个文件夹权限都设置为 0755(通过右键单击并选择文件权限来实现)。