【问题标题】:EC2 SSL not workingEC2 SSL 不工作
【发布时间】:2015-11-10 06:32:46
【问题描述】:

我正在运行一个 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>

它没有用。

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

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

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

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

谁知道问题出在哪里?

【问题讨论】:

  • 请列出您的安全组设置。最好有截图。
  • @tedder42 请注意,安全组设置不会导致“连接被拒绝”。它们只能导致“连接超时”。安全组通过静默丢弃而不是拒绝来阻止流量。
  • 很好,@Michael-sqlbot。

标签: apache ssl amazon-web-services amazon-ec2


【解决方案1】:

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

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

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

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

【讨论】:

    【解决方案2】:

    除了配置安全组以允许通过端口 443 的流量外,您可能还需要在服务器本身上打开端口 443。

    iptables -I INPUT 1 -p tcp --dport 443 -j ACCEPT

    如果这样可以解决问题,那么保存配置以便在重新启动后仍然存在:

    /sbin/service iptables save

    【讨论】:

      猜你喜欢
      • 2019-01-07
      • 2016-07-04
      • 2014-06-30
      • 2018-01-17
      • 1970-01-01
      • 2018-08-25
      • 2015-07-19
      • 2013-03-14
      • 1970-01-01
      相关资源
      最近更新 更多