簡體   English   中英

Apache始終加載相同的虛擬主機

[英]Apache always loads the same vhost

我有以下虛擬主機。 但是,使用https時,虛擬主機似乎總是解析為app.home,使其加載cloud.home的唯一方法是從虛擬主機中刪除app.home。 這使我相信它會忽略ServerName設置。

app.home.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
   ServerName app.home
  ProxyPreserveHost On
  ProxyRequests off
  ProxyPass /api/websocket ws://localhost:8123/api/websocket disablereuse=on keepalive=on
  ProxyPassReverse /api/websocket ws://localhost:8123/api/websocket disablereuse=on
  ProxyPass / http://localhost:8123/ disablereuse=on keepalive=on
  ProxyPassReverse / http://localhost:8123/ disablereuse=on#`

  RewriteEngine on
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)  ws://localhost:8123/$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /(.*)  http://localhost:8123/$1 [P,L]

SSLCertificateFile /etc/letsencrypt/live/app.home/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/app.home/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

cloud.home.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName cloud.home
    DocumentRoot "/var/www/cloud"

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

        ErrorLog ${APACHE_LOG_DIR}/cloud.home.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/cloud.home.access.log combined

SSLCertificateFile /etc/letsencrypt/live/cloud.home/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cloud.home/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Apache在端口443上接收到加密的連接。然后,它與客戶端的瀏覽器協商證書。 但是目前,它尚未讀取請求的域。 它必須首先協商證書以解密有效負載。

因此,Apache將始終使用找到的第一個與端口443匹配的VirtualHost。它將從該端口獲取證書。

要解決此問題,您必須:

  • 為您的第二個域設置第二個IP。 因此,Apache將配置為說domain1 == IP1,domain2 == IP2。
  • 為第二個域使用其他端口,例如:444。 但這並不方便,因為它不是默認值。
  • 使用SNI。 為此進行一些研究,時間太長,無法在此處進行說明。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM