_default_ VirtualHost 在端口 443 上重叠,第一个优先

_default_ VirtualHost 在端口 443 上重叠,第一个优先

我在同一台服务器(ubuntu 10.04)上运行两个 ruby​​ on rails 3 应用程序,均使用 SSL。

这是我的 Apache 配置文件:

<VirtualHost *:80>
ServerName example1.com
DocumentRoot /home/me/example1/production/current/public
</VirtualHost>
<VirtualHost *:443>
ServerName example1.com
DocumentRoot /home/me/example1/production/current/public
SSLEngine on
SSLCertificateFile /home/me/example1/production/shared/example1.crt
SSLCertificateKeyFile /home/me/example1/production/shared/example1.key
SSLCertificateChainFile /home/me/example1/production/shared/gd_bundle.crt
SSLProtocol -all +TLSv1 +SSLv3
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM
</VirtualHost>


<VirtualHost *:80>
ServerName example2.com
DocumentRoot /home/me/example2/production/current/public
</VirtualHost>
<VirtualHost *:443>
ServerName example2.com
DocumentRoot /home/me/example2/production/current/public
SSLEngine on
SSLCertificateFile /home/me/example2/production/shared/iwanto.crt
SSLCertificateKeyFile /home/me/example2/production/shared/iwanto.key
SSLCertificateChainFile /home/me/example2/production/shared/gd_bundle.crt
SSLProtocol -all +TLSv1 +SSLv3
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM
</VirtualHost>

问题是什么:

重新启动服务器后,它会给我一些如下输出:

 * Restarting web server apache2                                   
 [Sun Jun 17 17:57:49 2012] [warn] _default_ VirtualHost overlap on port 443, the first has precedence
 ... waiting [Sun Jun 17 17:57:50 2012] [warn] _default_ VirtualHost overlap on port 443, the first has precedence

当我用谷歌搜索为什么会出现这个问题时,我得到了如下的结果:

您不能将基于名称的虚拟主机与 SSL 一起使用,因为 SSL 握手(当浏览器接受安全 Web 服务器的证书时)发生在 HTTP 请求之前,HTTP 请求会识别适当的基于名称的虚拟主机。如果您计划使用基于名称的虚拟主机,请记住它们仅适用于非安全 Web 服务器。

但无法弄清楚如何在同一台服务器上运行两个 ssl 应用程序。

谁能帮我?

答案1

差不多了!

将其添加到 ports.conf 或 http.conf 并保留上述配置。

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.

    # !important below!
    NameVirtualHost *:443 
    Listen 443
</IfModule>

答案2

它还帮助我执行了“ /usr/sbin/apachectl -S”。此命令退出时显示同一路径上有两个“ssl.conf”文件。移动或删除有问题的文件,之后一切都会正常。

答案3

您可以将其添加到您的 apache 配置中/etc/apache2/ports.conf

<IfModule mod_ssl.c>                
    Listen 443                      
    <IfModule !mod_authz_core.c>    
        # Apache 2.2                
        NameVirtualHost *:443       
    </IfModule>                     
</IfModule>                         

(这在 apache 2.2 和 2.4 中都有效)

答案4

只需找到“Listen 443”的位置并粘贴到 NameVirtualHost *:443 上面即可。在我的情况下,它位于 ssl.conf 文件中

如果你重新启动 http 服务器,并且收到消息“Listen 443 已被弃用”,请删除“Listen 443”并仅保留 NameVirtualHost *:443

相关内容