Apache reverse proxy error page when proxied server is down

You can use the Apache ErrorDocument directive to do this. You should use a URL to point to your ErrorDocument otherwise if you use a filesystem reference you will get an additional 503 whilst trying to find it.

ErrorDocument 503 http://somehost.tld/errors/503.html

Here is solution without extra server or another port:

ProxyPass /http_errors/ !

#Actual proxy config, must be below exception!
ProxyPass / ajp://myserver:12345/

Alias /http_errors/ /var/www/http/
ErrorDocument 503 /http_errors/503.html

In short:

  1. Add proxy exception for some alias, like http_errors (must be placed before actual proxy rule)
  2. Map alias to real path (must be existing and accessible by Apache)
  3. Map given HTTP status code to certain file within alias

So for setup above, the file shown in case of problem is /var/www/http/503.html.