- Newest
- Most votes
- Most comments
Based on your description, there are several potential issues that could be causing the ALB health checks to fail for your EC2 instance:
-
Apache Configuration Issue: Your Apache configuration might not be correctly handling the health check requests from the ALB. The ALB sends health check requests to the root path you specified (/health.html), but your VirtualHost configuration has an Alias that might be interfering with how these requests are processed.
-
Security Group Configuration: While you've allowed HTTP traffic from the ALB security group to the EC2 instance, there might be an issue with how the return traffic is handled. Even though you've set
allow_all_outbound=Truefor the web security group, ensure that the ALB security group allows the return traffic. -
Health Check Path: The health check is looking for
/health.html, but your Apache configuration has an Alias that maps/appsto/var/www/html. This might cause confusion in how the server handles the health check request. -
Listening Interface: Your Apache might not be properly listening on all interfaces. While you've set
Listen 0.0.0.0:80, check that the server is actually binding to all interfaces.
Here are some recommendations:
- Simplify Apache Configuration:
- Remove the Alias directive temporarily to rule out path mapping issues
- Ensure your VirtualHost is correctly configured to serve content from the root path
- Verify Network Connectivity:
- Use
netstat -anton the EC2 instance to verify that Apache is listening on port 80 on all interfaces - Check if there are any firewall rules (like iptables) on the EC2 instance that might be blocking the ALB health checks
- Modify Health Check Configuration:
- Try using a simpler health check path like just
/instead of/health.html - Increase the timeout value to give more time for the health check to complete
- Check ALB Security Group:
- Ensure the ALB security group allows outbound traffic to the EC2 instance on port 80
- Test Direct Connectivity:
- Launch another EC2 instance in the same VPC and try to curl the health check endpoint from there to isolate if it's a network issue or an application issue
The fact that you can access the health check page locally on the instance but not from your Mac or the ALB suggests there's either a network configuration issue or an Apache configuration issue that's preventing external access to the server.
Sources
Health check failure with HTTP/2 in an ALB target group but succeeding with HTTP1.1 | AWS re:Post
Target Group health checks failing to private instances | AWS re:Post
Troubleshoot a Classic Load Balancer: Health checks - Elastic Load Balancing
ALB security group with cloudFront origin-facing prefix list ingress setting blocks target group health check for eks fargate | AWS re:Post
Hello.
From my workstation, trying curl -I http://<public‑ip>/health.html times out.
Direct access to EC2 fails because the EC2 security group only allows connections from the ALB.
Try adding your IP address to the EC2 security group.
Using this method, first try to make sure that you can access the health check path from outside the EC2 instance.
web_sg.add_ingress_rule(
ec2.Peer.ipv4('your ip address/32'),
ec2.Port.tcp(80)
)
Relevant content
asked 6 months ago
