我有 apache 服务设置,示例域为domain1.com 和domain2.com
我的 ssl.conf (etc/apache2/modes-enabled/ssl.conf)
NameVirtualHost *:443
<VirtualHost 172.17.0.122:443>
ServerAdmin [email protected]
DocumentRoot /var/www/domain1.com/htdocs
ServerName domain1.com:443
SSLEngine On
SSLProtocol all
SSLCertificateFile /var/ssl/domain1/domain1.crt
SSLCertificateKeyFile /var/ssl/domain1.key
SSLCertificateChainFile /var/ssl/intermediate.crt
</VirtualHost>
<VirtualHost 172.17.0.123:443>
ServerAdmin [email protected]
DocumentRoot /var/www/domain2.com/htdocs/
ServerName domain2.com:443
SSLEngine On
SSLProtocol all
SSLCertificateFile /var/ssl/domain2/domain2.crt
SSLCertificateKeyFile /var/ssl/domain2.key
SSLCertificateChainFile /var/ssl/intermediate.crt
</VirtualHost>
域1适用于http和https,域2仅适用于http,因为域2 https显示域1页面...我在服务器上有2个ip。
域 1 的虚拟主机 (etc/apache2/sites-enabled/domain1.com):
<VirtualHost *>
ServerAdmin [email protected]
ServerName www.domain1.com
ServerAlias domain1.com
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www/domain1.com/htdocs/
# CGI Directory
ScriptAlias /cgi-bin/ /var/www/domain1.com/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
ErrorLog /var/www/domain1.com/logs/error.log
CustomLog /var/www/domain1.com/logs/access.log combined
</VirtualHost>
apache2ctl -S 显示:
VirtualHost configuration:
172.17.0.122:443 www.domain1.com (/etc/apache2/mods-enabled/ssl.conf:77)
wildcard NameVirtualHosts and _default_ servers:
*:* is a NameVirtualHost default server www.domain3.com (/etc/apache2/sites-enabled/domain3.com:1)
port * namevhost www.domain3.com (/etc/apache2/sites-enabled/domain3.com:1)
port * namevhost www.domain2.com (/etc/apache2/sites-enabled/domain2.com:1)
port * namevhost www.domain1.com (/etc/apache2/sites-enabled/domain1.com:1)
这是正确显示domain1 https的配置
答案1
:443
从 ServerName 节中删除。它被视为名称的一部分,当不VirtualHost ServerName 条目匹配,Apache 提供它找到的第一个 VirtualHost 站点。
编辑哎呀。另外,仔细看看你的NameVirtualHost
陈述,因为它与你的VirtualHost
诗节形成鲜明对比。
您宣布将有多个使用该地址的 VHost *:443
,但随后在 上指定您的 VHost 172.16.0.123:443
。这些是不同的地址,Apache 不会承认它们。
更改您的NameVirtualHost
陈述或修改您的<VirtualHost>
诗节以使其匹配。