Debian Squeeze と Apache 2 を実行している VirtualBox ゲスト インスタンスに https サービスを設定しようとしています。
Win7ホストマシンからブラウザで仮想ホストのテストページを読み込もうとすると、エラーが発生します。ssl_error_rx_record_too_long同時に、Apacheエラーログには次のように表示されます。リクエスト内のメソッドが無効です \x16\x03\x01」というリクエストに応えて、この問題は VirtualBox ゲスト内で Apache を実行しているという事実とはおそらく無関係ですが、全体像を説明したいと思いました。
本当に興味深いのは、サイトが適切に読み込まれるようになったことですが、それはローカルホスト (つまり、VirtualBox Debian ゲスト内) からのリクエストに対してのみです。これを 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 には sites-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>