希望有人能帮我解决这个问题。我有2个IP,我可以用它来做这件事,并且需要在同一个Apache服务器上托管2个不同的安全(SSL)域。我读到Apache 2.2.something的时候,可以使用一个IP,使用某种插件,但我想尽可能地保持简单,并愿意使用两个IP来完成这个任务。我已经有了2个域名的签名证书。
我在这里发布的这个设置是可行的,但我遇到的问题是,当我访问domain2.net时,我收到一个浏览器警告,告诉我证书与域名不匹配,但与domain1.com匹配。
我使用CentOS 5和Apache 2.2.3。CentOS 有一个 ssl.conf 文件,这几行是我认为给我带来麻烦的地方。
SSLCertificateFile /etc/pki/tls/certs/domain1.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/domain1.com.key
我以为我可以在虚拟主机容器中覆盖这些值 并引用我所需要的密钥,但似乎不是这样的。当我在ssl.conf文件中注释掉这两行时,Apache不会重新启动。ssl_log提示。SSLCertificateKeyFile
这些是我的虚拟容器
<VirtualHost 2.2.2.2:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/domain2.net.crt
SSLCertificateKeyFile /etc/pki/tls/private/domain2.net.key
DocumentRoot "/var/www/domain2"
ServerName domain2.net
ServerAlias domain2.net
DirectoryIndex "index.php"
<Directory /var/www/html/domain2>
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 1.1.1.1:444>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/domain1.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/domain1.com.key
DocumentRoot "/var/www/html"
ServerName domain1.com
ServerAlias domain1.com
DirectoryIndex "index.php"
<Directory /var/www/html>
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
如何让这两个域使用SSL工作?我也试过在不同的IP上使用相同的端口,但同样,Apache不会重启。
我真的很迷茫,如果有人能帮我一把,我真的很感激。
很好的问题!我能够得到两个SSL证书。
我能够让两个SSL证书在同一台服务器上工作。你应该可以做到你想做的事情。
在你的配置中,我觉得很奇怪。
我建议在两个SSL保护的网站上使用443端口。你应该在apache的conf文件里有一个关于443端口监听的特殊指令。对我来说,它位于 etcapache2ports.conf 中。
Listen 443
.
看起来很奇怪,你的ServerName和ServerAlias都在每个虚拟主机上使用同一个域。试着让 ServerAlias 不同,或者不使用它。
ServerName domain1.com
ServerAlias www.domain1.com
.
我假设你在发布的conf中替换了你的IP和域名。即使它们不是你正在使用的实际IP,你可能要仔细检查它们是否能让你在SSL之外到达正确的地方(因为很明显SSL没有工作)。
.
检查apache2错误日志以获得更多信息。对我来说,日志位于:varlogapache2error.log。你可以设置它。 错误日志 varlogapache2error.log
最后,这里是我的ssl-default (ssl.conf),供你参考。我把我的域名和IP替换成了你在你的示例conf中使用的那些。我有多个子域与NameVirtualHost工作,因为我有一个通配符证书。
<IfModule mod_ssl.c>
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
NameVirtualHost 1.1.1.1:443
NameVirtualHost 2.2.2.2:443
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/ssl_access.log combined
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
# 1.1.1.1 = domain1.com
<VirtualHost 1.1.1.1:443>
ServerName www.domain1.com
ServerAdmin [email protected]
SSLEngine on
SSLCertificateKeyFile /var/www/ssl/domain1.key
SSLCertificateFile /var/www/ssl/wildcard.domain1.crt
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
DocumentRoot /var/www/domain1/www.domain1.com/web
DirectoryIndex index.php index.html
</VirtualHost>
<VirtualHost 1.1.1.1:443>
ServerName secure.domain1.com
ServerAdmin [email protected]
SSLEngine on
SSLCertificateKeyFile /var/www/ssl/domain1.key
SSLCertificateFile /var/www/ssl/wildcard.domain1.crt
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
DocumentRoot /var/www/domain1/secure.domain1.com/
DirectoryIndex index.php index.html
</VirtualHost>
# 2.2.2.2 = *.domain2.com
<VirtualHost 2.2.2.2:443>
ServerName admin.domain2.com
ServerAdmin [email protected]
SSLEngine on
SSLCertificateKeyFile /var/www/ssl/domain2.key
SSLCertificateFile /var/www/ssl/domain2.crt
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ErrorLog /var/log/apache2/error.log
DocumentRoot /var/www/domain2/secure.domain2.com/web
DirectoryIndex index.php index.html
php_flag display_errors on
php_value error_reporting 7
</VirtualHost>
</IfModule>
我希望这能帮助你!
你不需要一个单独的ssl.config文件,但如果你想使用一个,然后把你的SSL <VirtualHost XXX:443>
而不是httpd.conf文件中的容器。
另一种方法是将ssl.conf文件中的设置放到httpd.conf文件中,并将ssl.conf文件重命名为ssl.conf.bak(以备参考)。
把这个Apache命令放在第一个虚拟主机之前可能会有帮助。
SSLStrictSNIVHostCheck on
这使我能够在同一个IP上运行几个不同的域名,每个域名都有自己的密钥,而不会感到困惑。