Google App Engine Flex Health Checks on Docker Containers

211 views Asked by At

So I'm working on GAE Flex for my Craft CMS app. I'm using nginx and a mysql_tunnel on supervisor for this services.

I'm trying to configure the Health Checks Google offers to make sure that the services are up, but for some reason it is not working.

liveness_check:
  path: "/_ah/health.php"
  check_interval_sec: 30
  timeout_sec: 4
  failure_threshold: 2
  success_threshold: 2

This is my config on the app.yaml file and when I check the health checks on GAE it shows them returning a 301 instead of the 200 expected. I already tested turning my services down on the container and it shows the app as healthy even though it is not.

1

There are 1 answers

0
juanmrad On BEST ANSWER

For anyone having a similar Issue.

I was able to successfully fix this. Here is the problem It all came from my nginx config that is set to redirect all traffic to the www. version of my site as I need to enforce this.

My nginx is set to 301 all requests to www version of my site and this was causing the health job to redirect and return a 301 error. I added this server block on the top of my nginx.conf to receive al default server requests with the location of my health check to process them and this fixed it:

server {
  listen 8080 default_server;

  location ~ ^/_ah/ {
    root /var/www/public;
    try_files $uri =404;
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO       $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

    fastcgi_pass   localhost:9000;
    fastcgi_index  index.php;
  }
}

Hope this helps people that are trying to configure custom Health Checks on Google App Engine Flexible and have custom nginx rules on their site