动态端口和 AWS Applocation 负载均衡器和 ECS

Dav*_*han 0 amazon-web-services amazon-ecs amazon-elb aws-security-group

ELB 后面的 Docker 容器获得动态端口,这些端口自动向 ELB 注册,以便它们可以将流量重定向到它们。

为了让 ELB 可以访问您的 Web 服务器,您必须打开所有这些源自您的安全组内的端口 1024 - 65535。

有没有办法不必向一系列端口开放安全组,而只向 ELB 使用的罐开放?

Mar*_*ung 7

AWS 永远不会修改安全组,因为这可能会导致冲突和安全问题。唯一的例外是 Elastic Beanstalk 等服务。您可能必须按照论坛所说的进行操作并允许端口范围。

根据http://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PortMapping.html

The default ephemeral port range is 49153 to 65535, and this range is used for Docker versions prior to 1.6.0. For Docker version 1.6.0 and later, the Docker daemon tries to read the ephemeral port range from /proc/sys/net/ipv4/ip_local_port_range; if this kernel parameter is unavailable, the default ephemeral port range is used. You should not attempt to specify a host port in the ephemeral port range, because these are reserved for automatic assignment. In general, ports below 32768 are outside of the ephemeral port range.

如果你真的关心什么端口,就我所见,你有几个选择:

  1. 不要专门使用 ALB 和转发端口,因此您可以在 ELB 安全组中指定它们。
  2. 放置ALB相同的安全组为您的应用程序中,并使用内部安全组规则,例如TCP 0-65535sg-foo地方sg-foo是安全组两个ALB和应用程序都在
  3. 将 ALB 放在 security group 中sg-foo,并设置规则sg-appsg-app您的应用程序所在的安全组在哪里)并允许TCP 0-65535来自sg-foo内部的sg-app