4

Trying to create a maintenance mode for a apache proxy I've followed this apache wiki page:

https://cwiki.apache.org/confluence/display/HTTPD/MaintenancePage

I defined all this in a VirtualHost

# Redirect all requests to a 503 return code when in maintenance mode
ErrorDocument 503 /maintenance/index.html
RewriteEngine on
RewriteCond /var/www/maintenance/ALL -f [OR]
RewriteCond /var/www/maintenance/%{SERVER_NAME} -f
RewriteCond %{REQUEST_URI} !=/maintenance/index.html
RewriteRule ^ - [R=503,L]

the maintenance mode functions well. If I create a file named '/var/www/maintenance/ALL'

I am using this same VirtualHost to ProxyPass all requests (/) to a Remote Host

ProxyPass / https://RemoteHost:1234/
ProxyPassReverse / https://RemoteHost:1234/

The problem is, the ProxyPass is executed also if the RewriteRule is executed, what results in an document not found error, because the 503 error document is beeing looked for at the remote host, not at the apache proxy server

How do I prevent the ProxyPass directive from beeing executed, if "Maintenance Mode" is activated and the 503 error page should be shown?

New contributor
D M is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
4

You can add the following line to your configuration:

ProxyPass /maintenance/index.html !

The exclamation point can be read as "NOT" as in: "Do NOT proxy this URL."

The directive could go anywhere in your configuration, but I think it would make the most sense to go directly under the ErrorDocument 503 directive.

Like your ErrorDocument 503 directive, the proxy pass exception would be always active, but unlikely to be used. Other than maintenance mode, those directives could get in the way (cause a conflict) if your web app on the proxy wanted to return a 503 error, or if it tried to use the /maintenance/index.html path.

2
  • Thank you! It works as expected. What I do not fully understand is your hint regarding the conflicts that could be caused: You mean, if another application (on a remote) would like to call exactly that 503 Error Document URL, it could cause a conflict, because it can't call that URL, because it's "forbidden" by the ProxyPass /maintenance/index.html ! directive?
    – D M
    Sep 14 at 10:45
  • If the proxied app sends its own 503 error, your maintenance page may end up showing up. Sep 14 at 11:19

Your Answer

D M is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.