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개 답변
0

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

profile picture
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠