docker-nginx-redirect
docker-nginx-redirect copied to clipboard
Add healthcheck endpoint, set default ENV in Dockerfile
This pull request adds an optional healthcheck endpoint, useful for environments such as Kubernetes where readiness needs to be probed and monitored.
Four new environment variables are introduced:
SERVER_HEALTHCHECK_ENABLED- optionally enable a static healthcheck endpoint by settingSERVER_HEALTHCHECK_ENABLED=1- useful for deploying to Kubernetes or similar infrastructure where readiness needs to be confirmed and monitored
- disabled by default
SERVER_HEALTHCHECK_PATH- optionally override the location of the healthcheck endpoint- defaults to
/healthcheck
- defaults to
SERVER_HEALTHCHECK_RESPONSE_CODE- optionally override the status code of the healthcheck endpoint response- defaults to
200
- defaults to
SERVER_HEALTHCHECK_RESPONSE_BODY- optionally override the body of the healthcheck endpoint response- defaults to
alive
- defaults to
If SERVER_HEALTHCHECK_ENABLED=1 then /etc/nginx/includes/healthcheck.conf is included into default.conf.
In order for location matching against /${SERVER_HEALTHCHECK_PATH} it was necessary to wrap existing redirects in
location / {
...
# Existing redirect directives
...
}
Finally this pull request tidies up run.sh by declaring default ENV values at build time in the Dockerfile.
@robwatkiss Is this backward-compatible?