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.
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:
location
configuration (mentioned above) to the end of server
block in the file /etc/nginx/sites-available/default
and restart nginx serverhttp://localhost/health
should return response {"status":"UP"}