Generating useful error pages with Pound

We use Pound as a reverse-proxy and loud-balancing frontend to our web cluster here in the office. Today we had some NAT problems with our proxy server and ended up with some server downtime. Pound defaults to outputting a cryptic error message when it can’t reach a valid host:

The service is not available. Please try again later.

This isn’t very helpful to clients who probably have no idea why their site is unreachable. After getting NAT back up and running, I decided to work on replacing this error with something a little more useful.

Pound lets you create error files that will be displayed if all the hosts are unreachable. Just add any of the following strings to the ListenHTTP section of your pound.cfg file (man pound for more info):

Err414 "filename"
    #A file with the text to be displayed if an Error 414 occurs. Default: "Request URI is too long.".
Err500 "filename"
    #A file with the text to be displayed if an Error 500 occurs. Default: "An internal server error occurred. Please try again later.".
Err501 "filename"
    #A file with the text to be displayed if an Error 501 occurs. Default: "This method may not be used.".
Err503 "filename"
    #A file with the text to be displayed if an Error 503 occurs. Default: "The service is not available. Please try again later.".

Pound appears to cache these error files, so you’ll need to restart pound for it to pick up any changes to the error files you specified.

Presenting visitors with a more informative error message will do wonders to ease the stress of any unexpected downtime. I highly recommend it.

Originally posted here.