2012-05-15 85 views
0

我有一个奇怪的问题,当我使用SSL设置虚拟主机时,我的虚拟主机不受限制。除了虚拟主机不仅限于名称这一事实以外,一切都按预期工作。例如,如果我浏览到https://qa.example.com/,我就会得到正确的页面。但是,如果我浏览到https://foo.example.com/,我可以享受同一页面!我已经阅读http://httpd.apache.org/docs/2.2/vhosts/name-based.html的基于命名的配置,所以我不知所措。虚拟主机不尊重ServerName属性

这里是我的/etc/apache2/sites-enabled/mysite-ssl文件(我使用Ubuntu 12.04):

<IfModule mod_ssl.c> 
<VirtualHost *:443> 
    <IfModule dir_module> 
      DirectoryIndex login.html 
    </IfModule> 
    ServerAdmin [email protected] 
    ServerName qa.example.com 
    DocumentRoot /var/www/example 

    <Directory /> 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride None 
      Order allow,deny 
      allow from all 
    </Directory> 

    JkMount /axonify/* worker1 

    ErrorLog ${APACHE_LOG_DIR}/error.log 
    LogLevel warn 
    CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined 

    SSLEngine on 
    SSLCertificateFile "/etc/ssl/certs/star.example.com.crt" 
    SSLCertificateKeyFile "/etc/ssl/private/star.example.com.key" 
    BrowserMatch "MSIE [2-6]" \ 
      nokeepalive ssl-unclean-shutdown \ 
      downgrade-1.0 force-response-1.0 
    # MSIE 7 and newer should be able to use keepalive 
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown 
</VirtualHost> 
</IfModule> 

/etc/apache2/ports.conf文件是我定义了NameVirtualHost项:

NameVirtualHost *:80 
Listen 80 

<IfModule mod_ssl.c> 
    NameVirtualHost *:443 
    Listen 443 
</IfModule> 

<IfModule mod_gnutls.c> 
    NameVirtualHost *:443 
    Listen 443 
</IfModule> 

现在我/etc/apache2/sites-enabled/000-default文件也很简单:

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    RewriteEngine on 
    ReWriteCond %{SERVER_PORT} !^443$ 
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] 
</VirtualHost> 

我做n没有部署一个default-ssl站点,并且我只部署了一个启用了SSL的站点。

+0

我已经解决了这个问题。似乎我需要default-ssl文件,该文件指定作为任何不匹配虚拟主机的回退的''条目。 –

回答

0

我已经解决了这个问题。似乎我需要default-ssl文件,该文件指定<VirtualHost _default_:443>条目作为任何不匹配的虚拟主机的回退。