![具有自动子域名转发功能的通配符 SSL 证书](https://linux22.com/image/573330/%E5%85%B7%E6%9C%89%E8%87%AA%E5%8A%A8%E5%AD%90%E5%9F%9F%E5%90%8D%E8%BD%AC%E5%8F%91%E5%8A%9F%E8%83%BD%E7%9A%84%E9%80%9A%E9%85%8D%E7%AC%A6%20SSL%20%E8%AF%81%E4%B9%A6.png)
我有一台服务器,作为服务的一部分,用户被赋予他们自己的个性化子域名,即 username.servicename.com。每次发生这种情况时都生成个性化的虚拟主机条目并不是特别可行,所以我在 Apache 中使用了通配符虚拟主机文件。这很有效。
我现在正在尝试让 SSL 在其上工作。我有一个通配符 SSL 证书,其 CommonName 为 *.servicename.com,所以我认为我正在做我应该做的事情。但是...不起作用。HTTP 请求仍然工作正常,HTTPS 请求超时,并且日志中没有任何内容。我的配置有什么问题?
NameVirtualHost *:80
NameVirtualHost *:443
DirectoryIndex index.htm index.html index.php
<VirtualHost *:80>
ServerName servicename.com
ServerAlias *.servicename.com #wildcard catch all
VirtualDocumentRoot /var/www/%1
UseCanonicalName Off
IndexOptions FancyIndexing
### Use mod_rewrite to direct servicename.com to www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^servicename.com
RewriteRule (.*) http://www.%{HTTP_HOST}$1 [R=301,L]
### Logging
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /var/log/apache2/access_log_servicename combined
<Directory /var/www>
Options FollowSymLinks Indexes MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName servicename.com
ServerAlias *.servicename.com
VirtualDocumentRoot /var/www/%1
UseCanonicalName Off
IndexOptions FancyIndexing
### Use mod_rewrite to direct servicename.com to www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^servicename.com
RewriteRule (.*) https://www.%{HTTP_HOST}$1 [R=301,L]
### Logging
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /var/log/apache2/access_log_servicename combined
SSLEngine on
SSLProtocol all
SSLCertificateFile /etc/apache2/servicename.com.certificate
SSLCertificateKeyFile /etc/apache2/servicename.com.key
SSLCACertificateFile /etc/apache2/rapidssl.intermediateca
<Directory /var/www>
Options FollowSymLinks Indexes MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-ssl.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
答案1
由于错误配置而导致 Apache 请求超时的情况很奇怪。
连接超时通常是网络或防火墙的问题。例如,如果防火墙配置为不允许该端口上的流量,并且会丢弃这些数据包,则连接将超时。
查看您的设置中涉及的所有防火墙,这意味着您的本地网络传出规则、服务器网络传入规则和服务器本身的 iptables 规则。