SSL を使用して仮想ホストをセットアップすると、仮想ホストが制限されないという奇妙な問題があります。仮想ホストが名前だけに限定されないという事実を除いて、すべてが期待どおりに機能します。たとえば、https://qa.example.com/を参照すると、正しいページが表示されます。ただし、https://foo.example.com/を参照すると、同じページが表示されます! http://httpd.apache.org/docs/2.2/vhosts/name-based.htmlで名前付きベースの構成を読んだので、途方に暮れています。
これが私の/etc/apache2/sites-enabled/mysite-ssl
ファイルです(Ubuntu 12.04を使用しています):
<IfModule mod_ssl.c>
<VirtualHost *:443>
<IfModule dir_module>
DirectoryIndex login.html
</IfModule>
ServerAdmin admin@example.com
ServerName qa.example.com
DocumentRoot /var/www/example
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
JkMount /axonify/* worker1
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
SSLEngine on
SSLCertificateFile "/etc/ssl/certs/star.example.com.crt"
SSLCertificateKeyFile "/etc/ssl/private/star.example.com.key"
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>
私のファイルは、エントリ/etc/apache2/ports.conf
を定義する場所です。NameVirtualHost
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
NameVirtualHost *:443
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
NameVirtualHost *:443
Listen 443
</IfModule>
今、私の/etc/apache2/sites-enabled/000-default
ファイルも非常に単純です:
<VirtualHost *:80>
ServerAdmin admin@example.com
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
サイトを展開しておらずdefault-ssl
、SSL 対応のサイトを 1 つだけ展開しています。