ricktbaker / beanstalk-nginx-php-fpm

How to replace apache with nginx and php-fpm on AWS beanstalk
MIT License
74 stars 27 forks source link

Elastic Beanstalk Health Severe - FIX #8

Open curtismorte opened 6 years ago

curtismorte commented 6 years ago

To anyone who is using this repo (it's awesome by the way!), you might be running into some problems with the health of Elastic Beanstalk always being severe.

The source of the issue stems from the checks that the load balancer makes to elastic beanstalk:

# This is a log entry from /var/log/nginx/access_log
XXX.XX.XX.XX - - [24/Apr/2018:02:55:29 +0000] "GET / HTTP/1.1" 301 31 "-" "ELB-HealthChecker/2.0" "-"

The ELB expects by default that the status code returned should be 200. In this case, it's a 301 because of specific setup for the application/website (EG: force redirect to https).

This is caused by the load balancer settings for elastic beanstalk. To edit them:

  1. Go to your elastic beanstalk environment
  2. Select your specific application
  3. Use the sidebar to select "Configuration", then "modify" the Load Balancer.
  4. From "Processes", select the checkbox next to name "default" and use the "Actions" dropdown > "Edit"
  5. The next settings are really specific to your setup, however as an example you can change the port to protocol to be specific to your needs. Basically, make sure the load balancer health check gets the correct status code.

Hope this helps someone!