Apache Proxy Pass -> Custom 503 Error Document

7th February 2012 – 132 words

When the underlying server is not reachable, Apache generates an ugly 503 Status message. To change that and inform the users that our server will be up soon again (due to a deployment):

# Vhost/http conf
DocumentRoot /home/stefan/repos/empfehlungsbund/public
ProxyPreserveHost On

# if you running in production, maybe handling the assets by apache self, instead
# of thin/unicorn etc.
# ProxyPass /assets !


# Here the interesting lines:
ProxyPass /error-documents !
ErrorDocument 503 /error-documents/503.html
Alias /error-documents /home/stefan/repos/empfehlungsbund/public

# BTW: apache does not allow encoded slashes in URL,
# it will always generate 404. We used base64 encoded urls, which included this problem,
# to fix:
AllowEncodedSlashes on

Reposted from notes.it-jobs-und-stellen.de