除了默认 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>
更新 在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