【问题标题】:AWS application load balancer Cname Connection refusedAWS 应用程序负载均衡器 Cname 连接被拒绝
【发布时间】:2019-02-17 23:03:48
【问题描述】:

我有一个指向 ALB 的 Cname。当我直接点击 ALB DNS 时,我得到了一个连接,但它抱怨 SSL 证书,如此处所示 -

curl https://tek-q-appli.eu-west-1.elb.amazonaws.com/hello
curl: (51) SSL: no alternative certificate subject name matches target host name 'tek-q-appli.eu-west-1.elb.amazonaws.com'

因此,如果忽略此 SSL 错误,一切都很好 -

curl -k https://tek-q-appli.eu-west-1.elb.amazonaws.com/hello
<!DOCTYPE html>
<html>
<body>

<h1>World</h1>

</body>
</html>

当我点击指向 ALB 的 Cname 时,会生成一个连接被拒绝。我检查了 ACL 和 SG 在托管运行 Apache 的 Docker 的 ALB 和 EC2 上,如此处所示 -

curl https://example.com/hello
curl: (7) Failed to connect to example.com port 443: Connection refused

任何提示或指示将不胜感激。

【问题讨论】:

    标签: amazon-web-services ssl load-balancing


    【解决方案1】:

    第一个错误是正常的并且是意料之中的——平衡器不为其 AWS 分配的主机名提供 SSL 证书。

    第二个表明您的 DNS 不正确或您所做的更新尚未全局可见。 Curl 应该会向您显示它用于 example.com 的 IP 地址,并且每次连接时它都应该与平衡器的地址之一匹配。

    使用 dig 查找平衡器分配的主机名的 IP 以及为您的自定义域返回的 IP。除非/直到它们匹配,这表明存在 DNS 问题。

    【讨论】:

      【解决方案2】:

      感谢迈克尔的提醒。

      我认为这个问题与 httpd-vhosts.conf 有关,因为我关注了这篇文章

      Worth reading

      AWS ALB 背后的端到端加密以及让我成功的关键点是 -

      <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteCond %{HTTP:X-Forwarded-Proto} =http
          RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
        </IfModule>
      

      还有

        <IfModule mod_headers.c>
          # Disable preloading HSTS for now.  You can use the commented out header line that includes
          # the "preload" directive if you understand the implications.
          #Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
          Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains"
          Header always set X-Frame-Options DENY
          Header always set X-Content-Type-Options nosniff
        </IfModule>
      

      另外,我在 /etc/hosts 文件中有一个本地 DNS 条目用于测试。为了使用 Curl 测试实时域,我还需要删除本地主机文件。

      一切都好!

      【讨论】:

        猜你喜欢
        • 2020-03-01
        • 2018-02-26
        • 2020-04-11
        • 1970-01-01
        • 1970-01-01
        • 2018-07-18
        • 2019-10-13
        • 1970-01-01
        • 2017-09-27
        相关资源
        最近更新 更多