Apache 虚拟主机始终托管较早的内联

标签 apache ssl

除了默认的 SSL 之外,我的主机是 entis.bla.nltest.bla.nltest.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

最佳答案

我在 http://wiki.apache.org/httpd/NameBasedSSLVHosts 阅读了文档更接近,重要的一点是(强调我的):

In reality, Apache will allow you to configure name-based SSL virtual hosts, but it will always use the configuration from the first-listed virtual host (on the selected IP address and port) to setup the encryption layer*. In certain specific circumstances, it is acceptable to use a single SSL configuration for several virtual hosts. In particular, this will work if the SSL certificate applies to all the virtual hosts. For example, this will work if:

All the VirtualHosts are within the same domain, eg: one.example.com and two.example.com.

You have a wildcard SSL certificate for that domain (one where the Common Name begins with an asterix: i.e *.example.com)

关于Apache 虚拟主机始终托管较早的内联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19113662/

相关文章:

node.js - Apache 托管 php 网站和 Node js CORS 代理

php - Magento Connect权限不正确(尝试了许多解决方案均无效)如何解决此问题?

apache - "Using mod_ssl on Mac OS X"文档的当前版本?

php - 将 cURL 与 SNI(服务器名称指示)结合使用

c++ - 为什么我无法获得有关用户使用的证书的正确信息?

apache - 为什么代理下的 getContextPath() 返回的是 HttpServlet 内部的内部路径,而不是 Filter 内部的路径?

c# - HTTP 请求未经客户端身份验证方案 'Negotiate' 授权。身份验证 header

actionscript-3 - 联系 HTTPS REST 服务时出现 2032 Flex 错误

Android Emulator "Chain Validation Failed"将开发人员机器与自签名证书连接起来

apache - RHEL 7.3需要为apache tomcat设置代理服务器