无法连接到面向 Internet 的 NLB 将流量转发到私有实例

Cannot connect to internet-facing NLB forwarding traffic to a private instance

我已经配置了如下配置的云

  1. 具有 public 的 VPC 和两个可用性区域中的私有子网。 Public 子网配置了互联网网关,私有子网配置了 NAT 网关
  2. 面向 Internet 的网络负载均衡器允许在两个可用区中配置 TCP 流量
  3. 用于转发来自负载均衡器的流量的目标组
  4. 私有子网中的一个 EC2 实例在端口 80 上配置了 haproxy 侦听。它的安全组配置为在端口 80 上接受来自配置了 NLB 的两个子网的 TCP 流量
  5. 已将此实例添加到目标组,状态为健康

当我尝试访问 NLB DNS 时,它给我 'Connection timed-out' 错误。我期待当我点击 NLB DNS 时它应该将我转发到私有实例。我检查了许多 AWS 文档,例如 link,但仍然找不到解决此问题的方法。如果这还不够,请随时询问更多信息。

It's security group is configured to accept TCP traffic at port 80 from both the subnets in which NLB is configured

当目标通过实例 ID 注册时,面向 Internet 的 NLB 后面的实例的安全组需要允许来自 0.0.0.0/0 的流量——或者任何 public IP 地址范围需要通过平衡器访问它们——而不仅仅是平衡器的子网(健康检查需要)。

If your target type is an instance, add a rule to your security group to allow traffic from your load balancer and clients to the target IP.

https://aws.amazon.com/premiumsupport/knowledge-center/security-group-load-balancer/

与 ALB 和经典平衡器不同,当目标由 instance-id 配置时,NLB 流量具有外部客户端的源地址,这是安全组匹配的地址。