-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