除了默认的SSL之外,我拥有的主机是entis.bla.nl和test.bla.nl,当进入test.bla.nl时,所服务的页面来自entis.bla.nl。如果我通过IP访问服务器,就会得到默认的SSL主机,这应该是您所期望的,如下所示。
wildcard NameVirtualHosts and _default_ servers:
*:443 is a NameVirtualHost
default server bla.colo.bla.net (/etc/apache2/sites-enabled/default-ssl:2)
port 443 namevhost bla.colo.bla.net (/etc/apache2/sites-enabled/default-ssl:2)
port 443 namevhost entis.bla.nl (/etc/apache2/sites-enabled/live-entis:19)
port 443 namevhost test.bla.nl (/etc/apache2/sites-enabled/test-entis:21)Entis.bla.nl的配置:
<VirtualHost *:80>
ServerName entis.bla.nl
DocumentRoot /var/www/live/web
<Directory /var/www/live/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/certs/apache.crt
SSLCertificateKeyFile /etc/apache2/apache-ssl/apache.pem
ServerName entis.bla.nl
DocumentRoot /var/www/live/web
<Directory /var/www/live/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>测试配置:
<VirtualHost *:80>
ServerName test.bla.nl
DocumentRoot /var/www/test/web
<Directory /var/www/test/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
</Directory>
ErrorLog /var/log/apache2/test-error.log
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/certs/apache.crt
SSLCertificateKeyFile /etc/apache2/apache-ssl/apache.pem
ServerName test.bla.nl
DocumentRoot /var/www/test/web
<Directory /var/www/test/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
</Directory>
ErrorLog /var/log/apache2/test-error.log
</VirtualHost>Update在error.log中发现了这一点。不确定它是否直接相关,因为非ssl配置与ssl配置具有相同的问题。
[Tue Oct 01 13:06:07 2013] [notice] caught SIGTERM, shutting down
[Tue Oct 01 13:06:08 2013] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Oct 01 13:06:08 2013] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Oct 01 13:06:08 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.8 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/1.0.1 configured -- resuming normal operations发布于 2013-10-01 12:18:35
我阅读了http://wiki.apache.org/httpd/NameBasedSSLVHosts closer的文档,重要的部分是(强调我的):
实际上,Apache将允许您配置基于名称的SSL虚拟主机,但它将始终使用来自第一个列出的虚拟主机(在所选IP地址和端口上)的配置来设置加密层*。在某些特定情况下,对多个虚拟主机使用单个SSL配置是可以接受的。特别是,如果SSL证书应用于所有虚拟主机,这将有效。例如,如果: 所有的VirtualHosts都在同一个域内,例如: one.example.com和two.example.com。 您拥有该域的通配符SSL证书(公共名称以asterix: i.e *.example.com开头)
https://stackoverflow.com/questions/19113662
复制相似问题