I'm using Nginx to reverse proxy a nodejs instance that is currently timing out when an external service attempts to call a specific, secured api endpoint, generating 504 errors.
How can I setup Nginx to notify me (ie. via email) when it serves a 504? Because the api endpoint in question is secured and relies on specific information being passed, a generic monitoring solution won't work.
I'm very surprised I couldn't find any clear information on how to do this after googling for 15 mins.