我正在尝试在运行Debian Squeeze和Apache 2的VirtualBox guest虚拟机实例上设置https服务。
当试图从我的Win7主机上的浏览器中加载我的虚拟主机的testing页时,我收到一个错误“ ssl_error_rx_record_too_long ”。 同时,对于此请求,Apache错误日志显示“ 请求中的方法无效\ x16 \ x03 \ x01 ”。 这个问题可能与我在VirtualBox客户端中运行Apache的事实无关,但是想要绘制整个图片。
真正有趣的部分是,我已经到了网站加载正确的地步,但只适用于来自本地主机(即从VirtualBox Debian Guest)内部的请求。 我已经用l and和wgetvalidation了它们,它们按预期工作:
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.
下面的configuration文件(我已经剥离了一切从configuration,除了这个SSL站点的最低限度工作)
ports.conf:
Listen 443
httpd.conf:空
ssltest.intra :(虚拟主机configuration)
<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>
我validation了证书密钥位于指定的位置,并且它们是域的有效(未过期)密钥。 上面的虚拟主机configuration是由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的networking设置有关。 当我尝试在127.0.0.1到达本地时,一切正常。 当我尝试通过另一个NAT-ed接口(也是本地)连接(192.168.56.10)时,请求被拒绝。 任何提示如何解决?
我怀疑我的情况与user242156是一样的,很可能是原始的海报。 问题是我的configuration文件在启用了sites的网站上实际上并没有被读取,因为发行版的apache2.conf只包含sites-enabled / *。conf,我的文件没有使用这个扩展名,因为它不是必需的,例如Ubuntu。
所以正确的解决scheme是将ssltest.intra重命名为ssltest.intra.conf,或者如果这是不可接受的,请修改apache2.conf以添加行IncludeOptional sites-enabled/* 。
有同样的问题。 在我的情况下,以下解决scheme(Apache 2.2 / Debian Squeeze)
听起来似乎没有加载sslconfiguration。 经过虚拟主机configuration的许多尝试和错误之后,我在apache2.conf中添加了SSLconfiguration,而不是在虚拟主机指令部分。 这些端口在ports.conf中configuration。 之后,我的ssl正常工作。 看起来像加载configuration部分序列问题。
在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 (ie 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>
我有同样的问题,因为我的默认SSL没有启用
换一种说法:
a2ensite default-ssl service apache2 restart