I am trying to configure load-balancing for Fargate ECS. My understanding is that there are at least two target groups. One target group gets created along with the Application Load Balancer, and one target group gets created along with the ECS service.
My containers are running their service on TCP port 5000. I want the load balancer only to expose HTTPS over the regular 443 port, and redirect HTTP to HTTPS, or if that is difficult, just drop HTTP.
I see that Listeners allows specifying a whole bunch of things. However, I am confused by the target group created with the service. It - the IP
-type group, listens on port 80. Whether I select HTTP or HTTPS during the service creation/configuration.
My containers never get any traffic. I enabled load-balancer logging, it seems that the balancer does not understand what I want it to do. There "forward" "-" "-" "-" "-" "-" "-"
in the log at end of every request.
I ran aws elbv2 describe-target-groups
to get the definitions.
{
"TargetGroups": [
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:505963211XXX:targetgroup/ecs-fargate-api-service-tg/1ebb89754b34d072",
"TargetGroupName": "ecs-fargate-api-service-tg",
"Protocol": "HTTPS",
"Port": 80,
"VpcId": "vpc-e623dd9b",
"HealthCheckProtocol": "HTTPS",
"HealthCheckPort": "traffic-port",
"HealthCheckEnabled": true,
"HealthCheckIntervalSeconds": 30,
"HealthCheckTimeoutSeconds": 5,
"HealthyThresholdCount": 5,
"UnhealthyThresholdCount": 2,
"HealthCheckPath": "/cookie-policy",
"Matcher": {
"HttpCode": "200"
},
"LoadBalancerArns": [
"arn:aws:elasticloadbalancing:us-east-1:505963211XXX:loadbalancer/app/node-api-lb/f5e512a2678688f5"
],
"TargetType": "ip"
},
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:505963211XXX:targetgroup/node-api-tg/7544b53ab1720e0d",
"TargetGroupName": "node-api-tg",
"Protocol": "HTTPS",
"Port": 443,
"VpcId": "vpc-e623dd9b",
"HealthCheckProtocol": "HTTPS",
"HealthCheckPort": "traffic-port",
"HealthCheckEnabled": true,
"HealthCheckIntervalSeconds": 300,
"HealthCheckTimeoutSeconds": 5,
"HealthyThresholdCount": 5,
"UnhealthyThresholdCount": 2,
"HealthCheckPath": "/cookie-policy",
"Matcher": {
"HttpCode": "200"
},
"LoadBalancerArns": [
"arn:aws:elasticloadbalancing:us-east-1:505963211XXX:loadbalancer/app/node-api-lb/f5e512a2678688f5"
],
"TargetType": "instance"
}
]
}
What am I doing wrong? How should I go about setting up an application load-balancer for ECS Fargate to have HTTPS on the outside and route everything to the correct container PORT?
"Protocol": "HTTPS",
which means that your containers operate in HTTPS, they have proper SSL certicates? Or you meant HTTP here as usually is done? - MarcinHealthCheckProtocol": "HTTPS
which means that your ECS service will always be unhealthy if your containers use HTTP only. - Marcin"Protocol": "HTTPS",
to"Protocol": "HTTP",
, and set healtchcecks to HTTP if your containers use HTTP. Also you don't need second TG with port 443 as you don't use HTTPS in your containers. - Marcin