AWS ELB load balancers keeps failing health check

2019-09-20 19:10发布

问题:

On my EC2 instance my app is using Port 80, so cannot install Apache to simply get the ELB health check succeed.

For health check settings on the ELB, I am using port - HTTP/80 Ping Path - /index.html

And I have placed this index.html at the /var/www and /var/www/html/ directories as well.

<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<BODY>
   <H1>Hi</H1>
   <P>Hello to the World.</P> 
</BODY>
</HTML>

Any clue why this is failing health check? Without this, no traffic is going to my EC2 instance.

回答1:

Found the issue .. once I created a new security group for my LB and kept that as IB for the SG used for EC2 it worked fine. Keeping the same SG across LB & EC2 is making it break for whatever reason.

http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-groups.html



回答2:

As long as the page returns a 200 response, it should eventually pass the health check. The Health Check configuration includes the number of times a Health Check needs to return a good result and how often to check it. So, a Healthy count of 5 with a check every 30 seconds would take 2.5 minutes to return as Healthy.

If the HTTP health check is failing, try it with a TCP health check on port 8080 or 80 as per your configured server

Also, just in case, check that your VPC configuration allows a connection from the Load Balancer to the EC2 instance. This will be automatic if they are in the same Subnet, but Network ACLs can impact a connection between different Subnets.

also check following;

Is your instance behind the ELB running a web server ? If it is does it return an '200' (OK) ? If not then that's your problem.

If you are running a web service that returns a 200, is your security group open to the ELB? Meaning the ELB's source security group has to allowed into your instance's security group.

ping path should be the file name which you want to hit after you entered url of ELB in browser.