How to create an Apache error page for redirected Zope

500-errorapache-2.2custom-errorserrordocumentzope

I have some virtual hosts which are redirections to Zope server processes:

RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/%{HTTP_HOST}:80/theroot/VirtualHostRoot/$1 [L,P]

Of course, if the Zope process is not running, the redirection fails.
This can happen during restart of the instance (e.g. for an update), or for development/testing instances which are not supposed to run all the time. I'd like to have a friendly message in this case.

Thus, for the sole purpose of error handling, I defined a DocumentRoot:

DocumentRoot /var/zope-instances/my-instance/htdocs
ErrorDocument 500 /error-500.html
ErrorDocument 503 /error-500.html

Unfortunately it won't work; when trying a page while Zope is down, Apache tells me:

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Additionally, a 503 Service Temporarily Unavailable error was encountered while trying to use an ErrorDocument to handle the request.

The error documents are world-readable; the directories are world-executable.

What can I do to get the error page running?
Is there something special to consider because of mod_rewrite?

Best Answer

I finally found the solution (at this page); indeed, the problem was related to rewriting. I modified my virtual host like this:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/error-50[0-3].html$
RewriteRule ^/(.*) http://localhost:8080/...

(in my case, I get a status 503 when Zope is down; my condition is ready for more specific messages as well).

Since Apache didn't need to serve static content up to this point, I needed to enable the mime module; in my case:

cd /etc/apache2/mods-enabled
ln -s ../mods-available/mime.load .