How to implement the smart service page for nginx that appears when the primary server is unavailable?

I am looking for a nginx solution that will display a temporary message down when the underling server is unavailable.

I am looking for or a solution that will behave as follows:

  • displays the maintenance page (503) if the upstream server is unavailable.
  • displays a timeout (504) if the upstream server did not return any content in 60 seconds (it may take more to return all the content)
  • optional: find a way to measure the time taken when the service first went down, so I can display a service message: but send an email to the administrator if this still happens for more than 5 minutes.

To repeat, the whole point is to create a configuration that allows the server administrator to restart the servers upstream without having to manage maintenance messages.

+5
source share
1 answer

If you configure the timeout values ​​for proxy or fcgi requests (depending on your configuration) to your liking, you can really use the directive error_pageto configure different error pages for specific error codes.

The nginx documentation contains details, as kashyap has already pointed out .

Your optional requirement basically comes down to a monitoring service; most likely, this is not something better that can be done inside an external server.

0
source

All Articles