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

Moh*_*ain 69 https httpd.conf

我有两个运行在同一台服务器上的 ruby​​ on rails 3 应用程序,(ubuntu 10.04),都带有 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>
Run Code Online (Sandbox Code Playgroud)

什么问题:

在重新启动我的服务器时,它给了我一些这样的输出:

 * 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
Run Code Online (Sandbox Code Playgroud)

在谷歌上搜索为什么会出现这个问题时,我得到了这样的信息:

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

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

谁能帮我?

Dan*_*son 91

差不多好了!

将此添加到 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>
Run Code Online (Sandbox Code Playgroud)

  • 这不再适用于 Apache 2.4.7 (3认同)