AWS loadbalancer Egress 规则混乱

AWS loadbalancer Egress rule confusion

我有 4 台服务器和一个负载均衡器(类型:AWS::ElasticLoadBalancingV2::LoadBalancer)。我在服务器安全组的入口规则中有端口 80,在出口规则中有 0-65535。在用于入口规则的 LoadBalancer 安全组中,任何端口都可以工作,但是如果我将出口规则端口的端口从 80 更改为任何其他端口,我的负载平衡器将不起作用。对于出口规则中的 80 端口,它工作得很好。

它应该总是80吗?还是我的设置有问题?我是 AWS 的新手,非常感谢任何帮助。提前致谢。

通常 Loadbalancer 会为 public 公开端口 80443,但您可以公开其他端口,但对于网络应用来说最好只使用这两个端口。

but if I change port of egress rule port from 80 to any other, my loadbalancer doesnt work. For 80 port in egress rule it works perfectly.

它停止工作的两个原因

  • 应用程序正在侦听端口 80
  • 负载均衡监听器端口绑定80

在负载均衡器等正常情况下,您不应更改出口或出站规则。

负载均衡器安全组的推荐规则

The security groups for your load balancers must allow them to communicate with your instances. The recommended rules depend on the type of load balancer (Internet-facing or internal).

elb-security-groups

这是预期的行为。您的负载均衡器正在与端口 80 上的实例通信。因此它需要出站规则以允许您与您的实例建立连接。如果您 change/remove 端口,您的负载均衡器将失去与底层主机的连接,因此不会提供任何流量。

As per the documentation

Whenever you add a listener to your load balancer or update the health check port for a target group used by the load balancer to route requests, you must verify that the security groups associated with the load balancer allow traffic on the new port in both directions.

是不是一直都是80?

不,这取决于负载均衡器与附加实例通信的端口。在您的情况下,实例正在侦听端口 80。