问题
I have set up a a cluster, with 1 service containing 1 task. The task contains 2 docker containers. One for my UI (post 3000
) and one for my API (port 8080
). I can access both ports via [public-ip]:3000
and [public-ip]:8080
.
I then set up an Application Load Balancer
that points to the service. It points these target group
:
https://pasteboard.co/JFQfvD9.png
So now I CAN
reach the UI
via the DNS name
for the load balancer but the API calls that the application makes always fail with 404
.
This is the browser network request to the API
https://pasteboard.co/JFQjISle.png
Worth noting
The target group only goes to port 3000
. I would assume I need to target port 8080
here as well? They are also unhealthy and keept restarting but that is a side effect of not being able to find my health check endpoint which is 8080/api/ping
.
I am not really sure where I am going wrong here.
Any help would be much appreciated.
EDIT
Security Group https://pasteboard.co/JFRBE80.png
ALB https://pasteboard.co/JFRHgKU.png
TG Health check settings https://pasteboard.co/JFRIkRn.png
ALB info on ECS service https://pasteboard.co/JFRXYim.png
Trying to update ECS service https://pasteboard.co/JFRYyjz.png
Creating a new service, can only add 1 container to be load balanced https://pasteboard.co/JFS0yDW.png
回答1:
Based on the comments.
The issue was caused by misconfiguration of ports in target group of the load balancer.
The solution was to correctly set the ports so that they match those used in the ecs service.
来源:https://stackoverflow.com/questions/65384116/how-can-i-make-a-request-to-my-api-from-my-ui-when-they-are-both-containers-runn