I've seen the answers to nginx-how-to-run-a-shell-script-on-every-request, but my request is a bit different:
Whenever I have a problem with the back end (Mendix/Java specifically, but Python/django/plone also involved) which I'm proxying to, I would like to execute a script, but NOT return the results to the browser, ie. it is done asynchronously to the request, and perhaps issue a retry/reload/redirect page, but the important part for me is the script to be run whenever there is a gateway error.
The "need" is to either trigger a restart of the back-end, or issue an error/warning to the sysadmins.