title: Nginx - execute command on error (5xx gateway errors)
body: <p>I've seen the answers to <a href="https://stackoverflow.com/questions/22891148/nginx-how-to-run-a-shell-script-on-every-request">nginx-how-to-run-a-shell-script-on-every-request</a>, but my request is a bit different:</p>
  
  <p>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.</p>
  
  <p>The "need" is to either trigger a restart of the back-end, or issue an error/warning to the sysadmins.</p>