Add
server {
// ....
location /health {
access_log off;
add_header 'Content-Type' 'text/plain';
return 200 "healthy\n";
}
}
or if you need JSON support
server {
// ....
location /health {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 '{"status":"Healthy"}';
}
}
NOTE: Any status 200 or above, and below 400 is considered Alive/Success. So it does not matter what the Body itself is. It just matters what the return status_code is.
Also if you need to proxy to a remote backend service.
server {
// ....
location / {
proxy_pass http://backend;
health_check interval=10 fails=3 passes=2;
}
}
This way you can let your backend service handle the actual Status itself. Since just cause the container is ready and nginx is ready, does not always mean the backend service has connected to its dependent services such as database, etc.