amazon-web-servicesaws-code-deployaws-application-load-balancerhealth-check

PHP application behind application load balancer failing health check


I am trying to deploy a PHP through AWS CodeDeploy and am currently stuck on the AllowTraffic step in CodeDeploy. The application is on an EC2 instance behind an ALB. In the ALB, I am getting failing health checks. I have the PHP application code sitting in the following directory on the EC2 instance: /var/www/html/src. If I were to curl the private IP of the EC2 following by the directory where the code sits, I am getting an error 404 Not Found. Even though the index.php file is in that directory, I am unable to curl it. Currently I have security groups setup where the ALB security group allows any traffic from only HTTP, and all traffic from the ALB security group is allowed to reach the EC2 instance. I am able to curl the root of the instance and see Apache's default page.

If I were to adjust the health check settings on the ALB Target group, I get a 403 error when setting the health check to /. I get a 404 error when specifying the path to the directory that has the PHP application code.

Any advice on how I can get the instance to a healthy state for the ALB would be appreciated.

TG Health Check enter image description here

Application Load balancer security group allows traffic on port 80 EC2 instance security group allows traffic from Application Load Balancer security group.

The PHP application should be accessible on port 80, where Apache is running. The Application Load Balancer has only 1 listener that is set up for port 80, that forwards traffic to the target group.


Solution

  • The heath check path in your TG should be URL path, not the actual location on the EB instance. You can try with just /index.php:

    /index.php
    

    This assumes that your application is actually working and the only issue are health checks.