add a health check endpoint to nginx.

This commit is contained in:
Greyscale 2024-08-01 18:24:12 +02:00
parent 5d704fd447
commit c82ac9bad2
2 changed files with 8 additions and 2 deletions

View file

@ -106,7 +106,7 @@ EXPOSE 443
# A moderately long start period is important because while it IS serving a HTTP 200 immediately, it might not have
# completed probing the docker socket and generating the config yet.
HEALTHCHECK --start-period=30s \
CMD curl -s -o /dev/null -w "200" http://localhost:80/ || exit 1
CMD curl -s -o /dev/null -w "200" http://localhost:80/health || exit 1
# checkov:skip=CKV_DOCKER_3 This is a test container.
FROM ghcr.io/benzine-framework/php:nginx-8.2 AS test-app

View file

@ -22,8 +22,14 @@ server {
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
# Health check endpoint
location /health {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 '{"status":"Healthy"}';
}
}