我在虚拟托管服务器上安装了 OpenSuSE,运行多个虚拟网站。在正常的 http 上一切正常。除了 http 之外,我现在还想在 https 上运行我的虚拟站点之一。因此我购买了 SSL 证书。我已将证书文件复制到服务器:
SSLCertificateFile /etc/apache2/crt/site.crt
SSLCertificateKeyFile /etc/apache2/key/my.key
SSLCACertificateFile /etc/apache2/ca.txt
我已在文件“/etc/sysconfig/apache2”中的 Apache 模块中启用了 SSL
APACHE_MODULES="rewrite actions alias auth_basic authn_file authz_host authz_groupfile authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5 reqtimeout authn_core authz_core alias_module headers"
在 /etc/apache2 中我的listen.conf 说:
Listen 80
<IfDefine SSL>
<IfDefine !NOSSL>
<IfModule mod_ssl.c>
Listen 443
</IfModule>
</IfDefine>
</IfDefine>
我的虚拟主机配置文件显示:
<IfDefine SSL>
<IfDefine !NOSSL>
<VirtualHost *:443>
DocumentRoot "/srv/www/vhosts/dialogis-mediation.de/"
ServerName dialogis.coach:443
ServerAdmin [email protected]
ErrorLog /var/log/apache2/error_log
TransferLog /var/log/apache2/access_log
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile /etc/apache2/crt/site.crt
SSLCertificateKeyFile /etc/apache2/key/my.key
SSLCACertificateFile /etc/apache2/ca.txt
SSLCertificateChainFile /etc/apache2/ca.txt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/srv/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog /var/log/apache2/ssl_request_log ssl_combined
</VirtualHost>
</IfDefine>
</IfDefine>
现在问题: Apache 甚至没有启用端口 443。
我已经做了什么: 在“listen.conf”中的“Listen 80”之后直接将“Listen 443”添加到下一行。在这种情况下,服务器侦听端口 443,但在 Chrome 中给出错误:“ERR_SSL_PROTOCOL_ERROR”。
我不太确定我配置错了什么。
答案1
您还需要将 SSL 标志添加到 /etc/sysconfig/apache2 中的 APACHE_SERVER_FLAGS 中。
# Notably, to enable ssl support, 'SSL' needs to be added here.
# To enable the server-status, 'STATUS' needs to be added here.
#
# It does not matter if you write flag1, -D flag1 or -Dflag1.
# Multiple flags can be given as "-D flag1 -D flag2" or simply "flag1 flag2".
#
# Specifying such flags here is equivalent to giving them on the commandline.
# (e.g. via rcapache2 start -DReverseProxy)
#
# Example:
# "SSL STATUS AWSTATS SVN_VIEWCVS no_subversion_today"
#
APACHE_SERVER_FLAGS="SSL"
答案2
尝试在/etc/apache2我的listen.conf中:Listen 80 Listen 443
另请检查是否有其他应用程序正在使用端口 443,尝试释放该端口并重试!