无法让 SSL 与 Apache 一起工作

use*_*704 2 ubuntu ssl https apache-2.2

好的,所以我正在尝试将我的服务器配置为接受 SSL 连接,但我无法让它工作。我知道网站上有很多类似的问题,但到目前为止我遇到的每个问题似乎都没有帮助。

我会发布尽可能多的信息,希望能对您有所帮助。

我的 apache 版本是:2.2.14(在 Ubuntu 上运行)。下面的信息似乎表明 SSL 已配置且运行良好,但是当我尝试访问https://website.com 时,请求超时。

我通过 GoDaddy 获得了 SSL 证书,并按照流程生成了 .crt 文件。

我有以下文件:

/home/ubuntu/ssl/website.com.crt
/home/ubuntu/ssl/website.com.key
/home/ubuntu/ssl/gd_bundle.crt
Run Code Online (Sandbox Code Playgroud)

根据我的配置文件:

/etc/apache2/ports.conf

NameVirtualHost *:80
NameVirtualHost *:443
Listen 80
Listen 443
Run Code Online (Sandbox Code Playgroud)

/etc/apache2/sites-enabled/000-default-ssl

<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName website.com

DocumentRoot /var/www
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

LogLevel warn

CustomLog /var/log/apache2/ssl_access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

    SSLEngine on
SSLCertificateFile    /home/ubuntu/ssl/website.com.crt
SSLCertificateKeyFile /home/ubuntu/ssl/website.com.key
    SSLCertificateChainFile /home/ubuntu/ssl/gd_bundle.crt

<FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
    SSLOptions +StdEnvVars
</Directory>

BrowserMatch "MSIE [2-6]" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

该网站在正常 HTTP 上运行良好,因此我不会发布其配置(如果您愿意,我可以!)

  • Apache 重新启动没有错误。
  • 错误日志文件中似乎没有任何错误。

netstat 命令显示 apache 监听正确的端口:

    netstat -tap | grep https
    tcp   0   0   *:https   *:*   LISTEN   24840/apache2
Run Code Online (Sandbox Code Playgroud)

我遇到s_client命令也可能很有用。

    openssl s_client -connect localhost:443
Run Code Online (Sandbox Code Playgroud)

使用localhost的时候,好像一切正​​常(不能说我知道正常是什么,但是有很多相关的信息输出,并没有出现任何错误)。

    openssl s_client -connect <ip-address>:443
    openssl s_client -connect website.com:443
Run Code Online (Sandbox Code Playgroud)

以上两个输出错误:

    connect: Connection timed out
    connect:errno=110
Run Code Online (Sandbox Code Playgroud)

在尝试使 SSL 正常工作时,我遇到了很多上述诊断信息,但我不确定如何处理这些信息,现在我被卡住了。

如果您需要更多信息,请询问!

谢谢,汤姆。

Lad*_*ada 5

错误

Connection timed out
Run Code Online (Sandbox Code Playgroud)

表示openssl甚至无法在您服务器的端口 443 上完成 TCP 握手。

最可能的问题是您的iptables配置或托管服务提供商运行的外部防火墙。