Ubuntu で Apache 2.2 でマルチドメイン SSL を設定するには
マルチドメインSSL証明書は本来IPアドレスごとに1FQDNだった SSL ホストを、1IPアドレスで複数のFQDNに対応させるものです。
要するにhttpsでも名前ベースのバーチャルホストが使えるようになります。
Apache 2.2.12 以降で SNI(Server Name Indication)という SSLプロトコルに対する拡張機能がサポートされ、そのモジュールが mod_gnutls になります。
ただ Server Name Indication - Wikipedia, the free encyclopedia にある通り、SNI は Windows XP の IE ではサポートされないなど、まだまだ一般的使うには早そうです。
今回、さくら VPS サーバの Ubuntu 上でセットアップしたのでまとめておきます。
mod_gnutls をインストール・適用
# apt-get install libapache2-mod-gnutls # a2enmod gnutls
/etc/apache2/ports.conf を編集
mod_ssl は一応コメントアウト、mod_gnutil を有効にする。SSLStrictSNIVHostCheck はSNIに未対応のブラウザがデフォルトのCommon Nameを参照するように off にする。
#<IfModule mod_ssl.c> # # If you add NameVirtualHost *:443 here, you will also have to change # # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # # to <VirtualHost *:443> # # Server Name Indication for SSL named virtual hosts is currently not # # supported by MSIE on Windows XP. # NameVirtualHost *:443 # Listen 443 #</IfModule> <IfModule mod_gnutls.c> Listen 443 NameVirtualHost *:443 SSLStrictSNIVHostCheck off </IfModule>
サイトの設定
デフォルトを無効にして、それぞれのサイト定義ファイルを作りSSLの設定を各VirtualHost内に定義します。パスは共通の証明書なので同じなります。
デフォルトサイトの無効化
# a2dissite default-ssl
/etc/apache2/sites-available/first.domain.com
first.domain.com のサイト定義を作成
<VirtualHost *:443> ServerName first.domain.com SSLEngine on SSLCertificateFile /etc/apache2/ssl.crt/server.crt SSLCertificateKeyFile /etc/apache2/ssl.key/server.key SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt ( 省略 ) </VirtualHost *:443>
/etc/apache2/sites-available/second.domain.com-ssl
second.domain.com のサイト定義を作成
<VirtualHost *:443> ServerName second.domain.com SSLEngine on SSLCertificateFile /etc/apache2/ssl.crt/server.crt SSLCertificateKeyFile /etc/apache2/ssl.key/server.key SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt ( 省略 ) </VirtualHost *:443>
サイトの有効化
# a2ensite first.domain.com-ssl # a2ensite second.domain.com-ssl
再起動して反映
# /etc/init.d/apache2 restart
ちなみに実際使った証明書は SSL Certificates | Secure Your Data & Transactions - GoDaddy の Multiple Domains UCC になります。
また、当初 mod_sslで動かしてもとりあえず動作しました。エイリアス扱いのFQDNサイトのエラーログに、CNが異なるという旨の警告ログがたくさん出てしまいました。