title: How to implement a smart maintenance page for nginx that appears when the underlying server is down?
body: <p>I am looking for a nginx solution that would display a temporary down message when the underling server is down.</p>
  
  <p>I am looking or a solution that would behave like this:</p>
  
  <ul>
  <li>display a maintenance page (503) if the upstream server is down</li>
  <li>display a timeout (504) if the upstream server did not return any content in 60 seconds (it could take more to return the entire content)</li>
  <li>optionally: find a way of measuring the time spend from when the service went down first time so I can display a maintenance message: but send an email to the admin if this still happens for more than 5 minutes.</li>
  </ul>
  
  <p>To reiterate, the whole point is to make a config that allows the server administrator to restart the upstream servers without having to manage the maintenance messages.</p>