Https

_default_VirtualHost在443埠重疊,第一個優先

  • September 30, 2020

我在同一台伺服器(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

在Google搜尋為什麼會出現這個問題時,我得到了這樣的資訊:

您不能將基於名稱的虛擬主機與 SSL 一起使用,因為 SSL 握手(當瀏覽器接受安全 Web 伺服器的證書時)發生在 HTTP 請求之前,該請求標識了適當的基於名稱的虛擬主機。如果您計劃使用基於名稱的虛擬主機,請記住它們僅適用於您的非安全 Web 伺服器。

但無法弄清楚如何在同一台伺服器上執行兩個 ssl 應用程序。

誰能幫我?

差不多好了!

將此添加到 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>

它還幫助我執行“/usr/sbin/apachectl -S”。此命令出口顯示同一路徑上的兩個“ssl.conf”文件。移動或刪除罪犯文件,之後一切正常。

引用自:https://serverfault.com/questions/399616