SSLの設定 その2 【証明書のインストール】
前回の続きでSSLの設定です。
環境 Apache +COMODO SSL のバーチャルドメイン証明書
SSL証明書と言えばベリサインとか日本だったらSECOMとかが有名だけど、今回は、ひとつのサーバーで複数のドメインを利用しているとき、SSLを様々なドメインで使いたい、ということで、COMODOに決定。
サーバーにIPが一つしかなくても、複数のドメインでSSL設定ができます。
設定には証明書と、中間証明書の設定が必要になります。
2009年の設定でちょっと内容をかき換えました
□今回の目的
基本申し込みで3ドメインまで設定可能なのですが、まだドメインが一つしか入っていないサーバーなので、サブドメインでの設定とします。
Apacheの設定は /etc/httpd/conf/httpd.conf
www.sample.jp が基本で、/etc/httpd/conf.d/ssl.conf にて下記のような設定がされています。(特記部分のみ記載)
<VirtualHost xxx.xxx.xxx.xxx:443>
ServerName secure.sample.jp:443
</VirtualHost>
SSLEngine on
証明書無しでSSLが設定されている状態です。
secure.sample.jpでもSSLを使えるように設定します。
■インストール手順
1)COMODOからの「証明書.crt」と「中間証明書.ca-bundle」の2ファイルを前回作成したディレクトリ(/etc/httpd/conf/ssl2.crt/)にアップします。
2)SSLを使うドメインに関しては、/etc/httpd/conf/httpd.confではなく、
/etc/httpd/conf.d/ssl.conf で設定をします。(特記部分のみ記載)
まず、443でのNameVirtualHostを記述(めちゃくちゃ大事)
NameVirtualHost ***.***.***.***:443
1ドメインに付き、以下のドメイン設定をします。(その他諸々ご自由に。)
ServerName secure.sample.jp:443
DocumentRoot /var/www/html-secure
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
SSLCertificateFile /etc/httpd/conf/ssl2.crt/証明書.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl2.key/キー.key
SSLCACertificateFile /etc/httpd/conf/ssl2.crt/中間証明書.ca-bundle
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
ログだのDirectoryだのFilesだのも、一緒に設定してくださいね。
3)Apache再起動したらOK
/etc/rc.d/init.d/httpd restart
https://www.sample.jp/
https://secure.sample.jp/
も利用できるようになります。
*************
注意事項
Apacheを立ち上げた時に、
[warn] VirtualHost xxx.xxx.xxx.xxx overlaps with VirtualHost xxx.xxx.xxx.xxx, the first has precedence, perhaps you need a NameVirtualHost directive
というエラーが出て、https://secure.sample.jp/でhttps://www.sample.jp/が表示されるという状態になることがあります。
これは
/etc/httpd/conf.d/ssl.conf が
<VirtualHost xxx.xxx.xxx.xxx:443>
ServerName www.sample.jp:443
</VirtualHost>
かつ
/etc/httpd/conf/httpd.conf が
<VirtualHost xxx.xxx.xxx.xxx:443>
</VirtualHost>
だったり、
/etc/httpd/conf.d/ssl.conf が
<VirtualHost xxx.xxx.xxx.xxx:443>
ServerName www.sample.jp:443
</VirtualHost>
かつ
/etc/httpd/conf/httpd.conf が
<VirtualHost secure.sample.jp:443>
ServerName secure.sample.jp
</VirtualHost>
の時におこります。
xxx.xxx.xxx.xxxのIPに443ポートでアクセスする時の処理が被っているからです。
ご注意。
コメントする