- Newest
- Most votes
- Most comments
Hello.
What network mode are you using for your ECS tasks?
I think that if I used bridge mode, I would be able to connect from the public IP address of EC2.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-networking.html
I think this stackoverflow answer will be helpful.
https://stackoverflow.com/questions/51184501/aws-ecs-containers-are-not-connecting-but-works-perfectly-in-my-local-machine
Hello,
To access the webpage directly from the internet using the EC2 instance's public IP address, ensure that your ECS task definition uses the host or bridge network mode. If your ECS task definition is using the awsvpc network mode, this would explain why you can only access the webpage through a load balancer. The awsvpc network mode assigns a unique ENI to each task, load balancer can reach the task's Private IP. Task networking for the EC2 launch type
So that's probably a reason why running curl http://localhost and http://127.0.0.1 from within the EC2 instance isn't displays the Nginx welcome page
The task is allocated its own elastic network interface (ENI) and a primary private IPv4 address.
To ensure direct access from the internet using the EC2 instance's public IP, adjust your task definition to use the host or bridge network mode instead of the load balancer. However, be aware that using host mode has its disadvantages: you cannot run more than a single instance of a task on each host.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/networking-networkmode-host.html
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/networking-networkmode-bridge.html
Relevant content
- asked a year ago
- asked 2 years ago
