I am using the Nginx container to host a SPA application in Kubernetes.
Aside from the static files hosted for the SPA app, I also need to host the routes for health checks. So, the route /health/startup needs to return the text healthy when a GET request is sent to it.
I suppose I could just make a folder called "health" and then put a file in it called startup with the text healthy in it. But that seems a bit odd to me. And I worry that if the file structure may get changed and that then my health checks will start failing.
Is there a way, using the Nginx container to return a given value (ie "healthy")when a request comes to a specific route? (And not mess up the rest of my static file serving that is going on.)
Yes you can, in the configuration you are importing for the server, you can just do this:
location /health/startup {
add_header Content-Type text/plain;
return 200 'healthy';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With