Apache Proxy Pass -> Custom 503 Error Document

1 minute read

Out Of Date Warning

This article was published on 07/02/2012, this means the content may be out of date or no longer relevant.
You should verify that the technical information in this article is still up to date before relying upon it for your own purposes.

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