How can I make a request to my API from my UI when they are both containers running in the same task in ECS Fargate

孤街浪徒 提交于 2021-01-05 07:35:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!