Apache 上的 HTTPS 连接被拒绝

Apache 上的 HTTPS 连接被拒绝

我目前正在我的一个网站上试用 HTTPS,并从受信任的 CA 获得了试用证书。我已完成以下检查:

  • 根据 CA 的指示复制所有证书文件
  • 在 apache 上启用 mod_ssla2enmod ssl
  • 检查 PHP 是否已启用 OpenSSL
  • 在 Apache 中创建了一个新的虚拟主机,监听 443
  • 输入 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 在监听 443 端口lsof

  • 在本地以及从我自己的 PC 上使用 telnet 检查我是否可以连接到 443(服务器的 IP,而不是域;尝试连接到 my-site.com:443 时,提示连接失败)

然而,当我尝试浏览https://my-site.com(显然不是真正的域),我收到“连接被拒绝”错误。这是 Apache 日志的内容:

[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)

知道为什么会发生这种情况吗?

配置文件:

端口配置文件

Listen 443
NameVirtualHost *:80
Listen 80

虚拟主机配置

<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>

答案1

我终于注意到我还没有安装,从而解决了这个问题mod_ssl

sudo yum install mod_ssl

答案2

我添加了这个httpd.conf并重新启动了 Apache:

Listen 443

现在它正在发挥作用。

答案3

使用 Debian 安装,我只能假设它的原因与 Ubuntu 相同漏洞

重新排序 /etc/apache2/sites-available/default-ssl.conf 中的 listen 指令可以解决这个问题。 修补

答案4

我发现了这个问题 - 我正在为我的域名使用 Cloudflare 免费计划,这会主动阻止端口 443 上的任何连接。

相关内容