Apache SSL 配置 - 请求 \x16\x03\x01 中的方法无效

And*_*ázi 5 ssl debian https virtualhost apache-2.2

我正在尝试在运行 Debian Squeeze 和 Apache 2 的 VirtualBox 来宾实例上设置 https 服务。

当尝试从我的 Win7 主机的浏览器中加载我的虚拟主机的测试页面时,我收到错误“ ssl_error_rx_record_too_long ”。同时,Apache 错误日志显示“请求\x16\x03\x01 中的方法无效”对于此请求。这个问题可能与我在 VirtualBox 来宾中运行 Apache 的事实无关,但想为您描绘整个画面。

真正有趣的部分是,我已经到了站点可以正确加载的地步,但仅限于来自 localhost(即来自 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]
Run Code Online (Sandbox Code Playgroud)

保存文件的内容与预期完全一致。此外,如果我尝试通过纯文本 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.
Run Code Online (Sandbox Code Playgroud)

下面的配置文件(我已经从配置中剥离了所有内容,除了这个 SSL 站点工作的最低要求)

端口.conf:

Listen 443
Run Code Online (Sandbox Code Playgroud)

httpd.conf:空

ssltest.intra:(虚拟主机配置)

<VirtualHost *:443>

        ServerName ssltest.intra
        ServerAdmin webmaster@ssltest.org

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

我验证了证书密钥位于指定的位置,并且它们是域的有效(未过期)密钥。上述虚拟主机配置由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
Run Code Online (Sandbox Code Playgroud)

没有防火墙规则会阻止任何通过 443 的通信。

我错过了什么?

编辑显然这与 VirtualBox 网络设置有关。当我尝试以 127.0.0.1 本地访问该站点时,一切都按预期进行。当我尝试通过其他 NAT-ed 接口 (192.168.56.10) 连接(也在本地)时,请求被拒绝。有关如何解决该问题的任何提示?

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

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