dockeramazon-ecsaws-fargate

AWS Fargate Angular dockerize application not exposed to public ip


Starting out with Fargate to try to host an Angular dockerized application with NGINX. But it just wont work when I open the public ip to see the application. However the tutorial says it would.

I have tested the docker image and it works when I expose it on 8080 (good to know maybe is that in the Dockerfile I also have an expose 8080 included. Also NGINX config listens on 8080.

Steps taken:

Created a aws fargate cluster (serverless)

Task definition with below port mappings and 0,5cpu and image uri from private aws repository

Created Service with that task in it and tried with and without a 'application load balancer' with container 8080:8080 and listen on 8080 HTTP

Service starts and task is running, but I have tried all the IP's I could find in the browser and with curl - with and without the 8080 port added, but nothing seems to work. What may I missing?

"portMappings": [
{
"name": "ui-8080-tcp",
"containerPort": 8080,
"hostPort": 8080,
"protocol": "tcp"
}
],

I am going to try to cancel out my docker image and replace it with a base NGINX image, but in the meantime someone might have an answer?

I would expect a fargate cluster work out the box when you add a working docker container image on A ip like with K8s where you can curl the pod ip and check if that part is working. Now I click together something but can't 'peel the union'


Solution

  • You need to make sure you are deploying to a public subnet (a subnet with a route to an Internet Gateway), and you have configured ECS to assign a public IP address to the task. Then make sure the IP address you are using in the browser is the public IP address (not an IP address that is in your VPC's CIDR block).

    You also need to make sure you have a security group assigned to the ECS task that allows inbound traffic on port 8080.

    You need to make sure you are adding the port :8080 to the address you are trying to access in your browser. Without adding that, the browser will try to use the default port 80 which is not going to work here since you don't have anything listening on port 80.

    If none of the above fixes the issue, you may need to edit your question to include your full Nginx config file.


    I would expect a fargate cluster work out the box when you add a working docker container image on A ip like with K8s where you can curl the pod ip and check if that part is working.

    Running k8s on AWS, via AWS EKS, would have the same networking configuration requirements as AWS ECS, that I have outlined in my answer. There is definitely a minimum VPC/Security Group/Network configuration to make this sort of thing work, with ECS or EKS or anything else on AWS. Things aren't generally exposed to the public Internet on AWS by default, as that could be a security issue, you have to explicitly take a few steps to expose things to the Internet.