Apache SSL 設定 - 請求 \x16\x03\x01 中的方法無效

Apache SSL 設定 - 請求 \x16\x03\x01 中的方法無效

我正在嘗試在運行 Debian Squeeze 和 Apache 2 的 VirtualBox 來賓實例上設定 https 服務。

當嘗試從 Win7 主機的瀏覽器載入虛擬主機的測試頁面時,出現錯誤“ssl_error_rx_record_too_long」。同時,Apache 錯誤日誌顯示“請求 \x16\x03\x01 中的方法無效對於這個請求。

真正有趣的部分是,我已經達到了網站正確載入的程度,但僅限於來自本機主機(即來自 VirtualBox Debian Guest 內部)的請求。我已經用 lynx 和 wget 驗證了這一點,它們按預期工作:

wget https://ssltest.intra/ssl.html
--2013-09-13 07:26:49--  https://ssltest.intra/ssl.html
Resolving ssltest.intra (ssltest.intra)... 127.0.0.1
Connecting to ssltest.intra (ssltest.intra)|127.0.0.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 122 [text/html]
Saving to: `ssl.html.1'

100%[======================================>] 122         --.-K/s   in 0s

2013-09-13 07:26:49 (1.94 MB/s) - `ssl.html.1' saved [122/122]

保存的文件內容與預期完全一致。此外,如果我嘗試透過純文字 HTTP 與伺服器對話,它會正確地將我發送到一個更好的地方:

telnet ssltest.intra 443
Trying 127.0.0.1...
Connected to ssltest.intra.
Escape character is '^]'.
GET /ssl.html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
Instead use the HTTPS scheme to access this URL, please.<br />
<blockquote>Hint: <a href="https://ssltest.intra/"><b>https://ssltest.intra/</b></a></blockquote></p>
<hr>
<address>Apache/2.2.22 (Debian) Server at ssltest.intra Port 443</address>
</body></html>
Connection closed by foreign host.

下面的設定檔(我已經從設定中刪除了所有內容,除了這個 SSL 網站工作的最低限度)

連接埠.conf:

Listen 443

httpd.conf:空

ssltest.intra:(虛擬主機設定)

<VirtualHost *:443>

        ServerName ssltest.intra
        ServerAdmin [email protected]

        SSLEngine On
        SSLCertificateFile /etc/ssl/certs/ssltest.intra.crt
        SSLCertificateKeyFile /etc/ssl/certs/ssltest.intra.key

        DocumentRoot /var/www/ssltest.intra
        Options FollowSymLinks

        <Directory /var/www/ssltest.intra/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        php_value error_log /var/www/ssltest.intra/php_errors.log
        ErrorLog /var/log/apache2/ssltest.intra.error.log
        LogLevel warn
        CustomLog /var/log/apache2/ssltest.intra.access.log combined

</VirtualHost>

我驗證了憑證金鑰位於指定位置,並且它們是網域的有效(未過期)金鑰。上述虛擬主機配置是透過啟用的a2ensite ssltest.intra。 mod_ssl 已啟用,apache2 重新啟動(多次)。當我啟動 apache 時,這是日誌中的條目:

Apache/2.2.22 (Debian) PHP/5.3.3-7+squeeze14 with Suhosin-Patch mod_ssl/2.2.22
OpenSSL/1.0.1e mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

沒有防火牆規則可以阻止任何超過 443 的通訊。

我缺什麼?

編輯顯然這與 VirtualBox 的網路設定有關。當我嘗試透過 127.0.0.1 造訪本地網站時,一切都按預期進行。當我嘗試透過其他 NAT 介面 (192.168.56.10) 連接(也在本地)時,請求被拒絕。關於如何解決這個問題有什麼建議嗎?

答案1

我懷疑我的情況與 user242156 相同,而且很可能是原始發文者。問題是,sites-enabled/ 中的設定檔實際上並未被讀取,因為發行版的apache2.conf 僅包含site-enabled/*.conf 並且我的檔案沒有使用該副檔名,因為它不是必需的,例如,Ubuntu。

因此,正確的解決方案是將 ssltest.intra 重新命名為 ssltest.intra.conf,或者如果這確實不可接受,請修改 apache2.conf 以新增行IncludeOptional sites-enabled/*

答案2

有同樣的問題。在我的情況下,以下解決方案有效(Apache 2.2/Debian Squeeze)

監聽時似乎未載入 ssl 配置。在對虛擬主機配置進行多次嘗試和錯誤之後,我在 apache2.conf 中新增了 SSL 配置,而不是在虛擬主機指令部分。連接埠在 ports.conf 中配置。之後我的 ssl 工作正常。看起來像是載入配置部分的順序問題。

在 apache2.conf 底部新增了 SSL 部分

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/<server certificate filename>
SSLCertificateKeyFile /etc/apache2/ssl/<privatekey filename>
SSLCACertificateFile /etc/apache2/ssl/CaCert.crt

ports.conf 中已存在條目

# If you just change the port or add more ports here, you will likely also
 have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
Listen 80
<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
Listen 443
</IfModule>

相關內容