【问题标题】:Apache ERR_CONNECTION_REFUSED over SSL on UbuntuUbuntu 上基于 SSL 的 Apache ERR_CONNECTION_REFUSED
【发布时间】:2016-12-22 15:54:17
【问题描述】:

我正在尝试在 Ubuntu 上设置 Apache (2.4) 服务器。现在我只是想让它为来自/var/www/html 的静态页面提供服务(尽管最终我想运行一个 WSGI Python 应用程序)。

这是我的sites-available/website.conf 文件:

<VirtualHost *:443>
        ServerAdmin email@gmail.com
        ServerName website.com:443
        SSLEngine on
        SSLCertificateFile /root/website.csr
        SSLCertificateKeyFile /root/website.key
        DocumentRoot /var/www/html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

(将我的实际域替换为“网站”。)

当我尝试通过访问我的域名或服务器的 IP 来连接到此站点时,Chrome 会给我ERR_CONNECTION_REFUSED(“无法访问此站点”)。

我也尝试过 telnet:

root@website:/etc/apache2# telnet localhost 443
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

当我从配置文件中注释掉所有与 SSL 相关的行时,我可以通过 telnet 进行连接,但 Chrome 给了我ERR_SSL_PROTOCOL_ERROR(“此站点无法提供安全连接”,我想这是有道理的)。

这也是我的ports.config,如果有帮助的话:

Listen 80

<IfModule ssl_module>
        Listen 443
        NameVirtualHost *:443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

(是的,SSL 模块已启用。)

还有我在类似问题中经常看到的apache2.conf 部分:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

这是我第一次设置 Apache 服务器,所以我猜我在这里搞砸了一些简单的事情?

【问题讨论】:

  • 你能不能把Listen 443改成Listen 443 https(虽然443端口应该默认是https)

标签: apache ubuntu ssl


【解决方案1】:

检查这里是否激活了ssl模式:

sudo a2enmod ssl

sudo service apache2 重启

【讨论】:

  • 是的。在先检查了许多其他问题之后,这是我的最后一步。
【解决方案2】:

我的问题在这里:

SSLEngine on
SSLCertificateFile /root/website.csr
SSLCertificateKeyFile /root/website.key

我链接到.csr,而不是.crt。我也没有链接到中间的东西。

现在是这样,修复了它:

SSLEngine on
SSLCertificateFile /root/domain.crt
SSLCertificateKeyFile /root/domain.key
SSLCertificateChainFile /root/DigiCertCA.crt

【讨论】:

    猜你喜欢
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 2015-08-04
    • 2017-03-06
    • 1970-01-01
    • 2021-09-04
    • 1970-01-01
    • 2012-01-22
    相关资源
    最近更新 更多