-2

ELB后面的Docker容器获得了动态端口,这些动态端口通过ELB自动注册,以便他们可以将流量重定向到它们。动态端口和AWS应用程序负载均衡器和ECS

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

有没有办法不必开放一个安全组到一定范围的端口,但只有ELB使用的锅?

回答

3

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在安全组sg-foo,和把规则上sg-app(其中sg-app是安全组应用程序是),并允许交通TCP 0-65535sg-foosg-app