在主机名上使用了Apache SSL证书

我在我们的一台服务器上设置了大容量虚拟主机,允许我在某个目录中基本上创build一个符号链接,并立即在http和https上提供该主机。 如果所有的主机名都在同一个域中(通配符证书),但是不是这样的,那么这种方法很好用。 让我给你看我的VirtualHost容器:

<VirtualHost 1.2.3.4:443> SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW ### Mass SSL Vhosts ### RewriteEngine on # define two maps: one for fixing the URL and one which defines # the available virtual hosts with their corresponding # DocumentRoot. RewriteMap lowercase int:tolower # 2. make sure we have a Host header RewriteCond %{HTTP_HOST} !^$ # 3. lowercase the hostname RewriteCond ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$ # 5. finally we can map the URL to its docroot location # and remember the virtual host for logging puposes RewriteRule ^/(.*)$ /wwwroot/vhosts/%{HTTP_HOST}/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}] <Directory "/wwwroot/vhosts/"> Options FollowSymLinks AllowOverride All </Directory> <Files ~ "\.(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> <Directory "/var/www/cgi-bin"> SSLOptions +StdEnvVars </Directory> ErrorLog /var/log/httpd/ssl_error_log TransferLog /var/log/httpd/ssl_access_log LogLevel warn SSLCertificateFile /etc/pki/tls/certs/wildcard.foo.com.crt SSLCACertificateFile /etc/pki/tls/certs/wildcard.foo.com.intermediate.crt SSLCertificateKeyFile /etc/pki/tls/private/www.foo.com.key SetEnvIf User-Agent ".*MSIE.*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost> 

这个设置任何时候我想创build一个something.foo.com域。 我只是在/ wwwroot / vhosts中创build一个符号链接到用户的目录,并且它可以工作。 我现在想创build一个something.bar.com域。 再次,我可以创build它,并将其放入,并且http://something.bar.com将工作。 但是,我不能工作,因为上面明确定义的证书是https://something.bar.com 。

有没有办法根据主机名在VirtualHost容器内分支来使用不同的SSL证书?

你看过SNI(服务器名称指示)吗? 例如使用mod_ssl或mod_gnutls:

  • Apache2 / SSL和基于名称的虚拟主机
  • 带有mod_gnutls的基于SSL的基于名称的Apache虚拟主机