我目前正在尝试在我的网站上使用HTTPS,并从受信任的CA获得试用证书。 我已经通过了以下清单:
a2enmod ssl在apache上启用mod_ssl input了SSL指令:
SSLEngine on
SSLCertificateKeyFile /etc/ssl/ssl.key/server.key
SSLCertificateFile /etc/ssl/ssl.crt/api_my_site_com.crt
SSLCertificateChainFile /etc/ssl/ssl.crt/apimysite.com-bundle
只检查Apache是用lsof监听端口443
但是,当我尝试浏览到https://my-site.com (显然不是真正的域),我得到一个“拒绝连接”的错误。 这是Apachelogging的内容:
[Sat Jul 20 22:50:34 2013] [info] Loading certificate & private key of SSL-aware server [Sat Jul 20 22:50:34 2013] [info] Configuring server for SSL protocol [Sat Jul 20 22:50:34 2013] [info] RSA server certificate enables Server Gated Cryptography (SGC) [Sat Jul 20 22:50:34 2013] [info] [client ::1] Connection to child 0 established (server my-site.com:443) [Sat Jul 20 22:50:34 2013] [info] Seeding PRNG with 656 bytes of entropy [Sat Jul 20 22:50:34 2013] [info] [client ::1] SSL library error 1 in handshake (server my-site:443) [Sat Jul 20 22:50:34 2013] [info] SSL Library Error: 336027900 error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol speaking not SSL to HTTPS port!? [Sat Jul 20 22:50:34 2013] [info] [client ::1] Connection closed to child 0 with abortive shutdown (server my-site:443)
任何想法为什么发生这种情况?
configuration文件:
ports.conf
Listen 443 NameVirtualHost *:80 Listen 80
虚拟主机configuration
<VirtualHost *:443> DocumentRoot /var/www/mysite/sandbox/api ServerName api.my-site.com RewriteEngine on RewriteRule ^/v1/* /v1/api.php [L] RewriteRule ^/* /index.php [L] <Directory "/var/www/mysite/sandbox/api"> allow from all </Directory> Options -MultiViews ErrorDocument 404 /404.html AddDefaultCharset utf-8 <IfModule mod_mime> AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml </IfModule> <IfModule mod_rewrite> Options +FollowSymlinks RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] </IfModule> <IfModule mod_autoindex> Options -Indexes </IfModule> <IfModule mod_rewrite> RewriteCond %{SCRIPT_FILENAME} -d [OR] RewriteCond %{SCRIPT_FILENAME} -f RewriteRule "(^|/)\." - [F] </IfModule> <FilesMatch "(^#.*#|\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|sw[op])|~)$"> Order allow,deny Deny from all Satisfy All </FilesMatch> FileETag None SSLEngine on SSLCertificateKeyFile /etc/ssl/ssl.key/server.key SSLCertificateFile /etc/ssl/ssl.crt/api_my_site_com.crt SSLCertificateChainFile /etc/ssl/ssl.crt/apimysite.com-bundle ErrorLog /var/www/mysite/api.log LogLevel info </VirtualHost>
使用Debian安装,我只能假设它和这个Ubuntu的bug一样 。
重新排列/etc/apache2/sites-available/default-ssl.conf中的listen指令解决了这个问题。 补丁
由于您已经创build了一个虚拟主机,所以新主机的SSL应该与端口80不同,因为您已经通过443为端口80启用了SSL。所以对于新的虚拟主机,请尝试636并查看。
我发现这个问题 – 我正在为我的域使用Cloudflare Free计划,并且正在主动阻止端口443上的任何连接。
我终于通过注意到我没有安装mod_ssl解决这个问题。
sudo yum install mod_ssl