I'm new to AWS. So I have an ECS cluster with 2 instances. Each instance runs 1 task via a service. Both instances are in the same target group which has port 80 open. Each tasks runs nginx(port 80 connected to host port 80), react and express container. I also have a rds instance.
Now, I'm trying to load balance to the nginx container. When I try to assign a load balancer to this target group, it doesn't load any web page, just shows blank. But when I have only 1 instance running then it works fine, the web pages loads.
I tried to check and reconfigure all my security groups to see if they are causing the issue. But haven't worked.
Here's my task definition
{
"family": "task-td",
"containerDefinitions": [
{
"name": "task-client",
"image": "public.ecr.aws/react-container",
"cpu": 0,
"portMappings": [
{
"name": "task-client-5173-tcp",
"containerPort": 5173,
"hostPort": 5173,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [],
"mountPoints": [],
"volumesFrom": []
},
{
"name": "task-server",
"image": "public.ecr.aws/express-api-container",
"cpu": 0,
"portMappings": [
{
"name": "task-server-3000-tcp",
"containerPort": 3000,
"hostPort": 3000,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [
{
"name": "PGHOST",
"value": "rds.amazonaws.com"
},
{
"name": "PGPORT",
"value": "5432"
},
{
"name": "PGUSER",
"value": "postgres"
},
{
"name": "PGDATABASE",
"value": "task"
},
{
"name": "PGPASSWORD",
"value": "postgres123"
}
],
"mountPoints": [],
"volumesFrom": []
},
{
"name": "nginx",
"image": "public.ecr.aws/nginx-container",
"cpu": 0,
"links": [
"task-client",
"task-server"
],
"portMappings": [
{
"name": "nginx-80-tcp",
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [],
"mountPoints": [],
"volumesFrom": []
}
],
"taskRoleArn": "/ecsTaskExecutionRole",
"executionRoleArn": "/ecsTaskExecutionRole",
"networkMode": "bridge",
"requiresCompatibilities": [
"EC2"
],
"cpu": "256",
"memory": "256",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
}
}