EC2 SSL 不工作

Cod*_*ode 2 apache ssl amazon-ec2 amazon-web-services

我正在运行 EC2 微型实例 (Amazon Linux),但似乎无法使 ssl (https) 正常工作。

我在 Chrome 中遇到的错误是“ERR_CONNECTION_REFUSED”(没有发送数据)。

我在我的 AWS 控制台中为安全组启用了 HTTPS 入站流量。

我在 /etc/httpd/conf/httpd.conf 文件中添加了这个。(example.com 是我网站的占位符)

<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / https://example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName example.com
    SSLEngine on
    SSLCertificateFile /etc/ssl/example_com.crt
    SSLCertificateKeyFile /etc/ssl/example_com.key
    SSLCertificateChainFile /etc/ssl/example_com.ca-bundle
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

它没有用。

因此,为了测试 VirtualHost,我将其替换为以下内容:

<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / https://google.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName example.com
    Redirect permanent / https://google.com/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

http://example.com像预期的那样重定向到 google,但https://example.com没有。

有谁知道是什么问题?

Mic*_*bot 6

连接被拒绝意味着您的服务器的 IP 堆栈主动拒绝了端口 443 (https) 上的传入连接,因为没有服务正在侦听端口 443。

这些天我们在我的操作中使用的 Apache 越来越少,因为其他一些替代方案的成熟度,所以我在这里可能有点生疏,但我有理由相信你的服务器,尽管配置了一种响应方式对端口 443 上的请求...实际上并未侦听端口 443 上的连接。

listen 80的 apache 配置中可能有某个地方。这将需要伴随listen 443基于 httpd.apache.org/docs/2.2/bind.html:

当 Apache 启动时,它会绑定到本地机器上的某个端口和地址并等待传入​​的请求。默认情况下,它侦听机器上的所有地址。但是,可能需要告诉它侦听特定端口,或仅侦听选定地址,或两者的组合。这通常与虚拟主机功能结合使用,后者决定了 Apache 如何响应不同的 IP 地址、主机名和端口。