Search code examples
reactjsdockeramazon-ec2amazon-ecs

Dockerized react js site on ECS showing not healthy when the site is reachable


We have Dockerized a react js site on in AWS ECS with a load balancer. The task definitions are being run on fargate with linux.

The issue we are having is that the target group is always reporting unhealthy. We have pathed the health check to special built portion of the site just for the health check. That path returns a 304 when hit. We have changed the health check range to 200-304. The response on the failed health checks was a 404.

As a test we set the health check to 404 == healthy. When we did that the site stayed up and we were able to use all functionality. The healthy path we made was returning a 304 as well even though it was saying in the health check it was returning 404.

  • We have tried Increasing the timeout and the grace period for the health check.
  • changing ports (and making sure those ports were open)
  • changing where the /health is hitting
  • change the LB redirect port
  • we have made sure the image is the most recent working one
  • also opened up ports 443 and 80 on the load balance and the task.

We are out of ideas and while the site is 100% functional with a healthy == 404 we don't want to leave it this way.

How can we get healthy to be 200 or 304 or anything other than 404?


Solution

  • It turns out that do to routing and how we were handling the paths it was returning a 304 because when it would go to hit the path we were putting in for the healthy check it was going through a redirect which constituted a 304. We fixed it by pointing the healthy check at something in front of those route, in our case the tab image.