dockernginxhealth-check

Simple healthcheck endpoint in nginx server container


I have a docker container running with nginx server.

I want to provide a rest-interface/endpoint to check the health of the server and container. E.g. GET http://container.com/health/ which delivers "true"/OK or "false"/NOK.

What is the simplest and quickist solution or best practice?

P.S. The server serves as a file browser, i.e., with enabled Directory Index Listing.


Solution

  • The following configuration worked for me with nginx version: nginx/1.14.0 (Ubuntu):

        location = /health {
                access_log off;
                add_header 'Content-Type' 'application/json';
                return 200 '{"status":"UP"}';
        }
    

    To test it: