Not able to access the nodejs application properly from ecs containers when configured to an aws load load balancer

0

I have a sample development mode nodejs application. I've used the following for Dockerfile

FROM node:14-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

EXPOSE 5180

CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]

Built an image and pushed it to aws ecr repo and created a cluster in ecs I defined a task and here I'm using dynamic port mapping (0 5180)since my requirement is to run multiple containers in a single EC2. The task is then made into a service using EC2 where I've used AWS load balancer.

I'm using an application load balancer with listeners 80 and health check at Working Directory as "/app" as mentioned in the Dockerfile. This has been attached the ECS service as well.

My problem is when tasks are running at a steady state and I checked the Load Balancer target group and the targets show healthy but when I tried to access my application using the DNS of ALB the browser is trying to reach the page and the page becomes blank after multiple refreshing I'm able to reach the page but this is not consistent.

I open the container's security group to all traffic and I tried accessing a single task with its dynamic port number and it's working but not with the ALB DNS.

已提問 1 年前檢視次數 316 次
1 個回答
0

Are there any errors in the application log or response status?

profile picture
專家
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南