I have an Apache 2.4 server on Windows Server 2008 R2 that I use as a reverse proxy. It has been working fine and serves about 15 virtual hosts. Whenever a host fails, I want to display a web page indicating that the server is down temporarily. I placed the custom error file in a folder in the htdocs folder called errors. I have the following directives in the httpd.conf file:
ErrorDocument 500 /errors/default.html
ErrorDocument 502 /errors/default.html
ErrorDocument 503 /errors/default.html
ErrorDocument 504 /errors/default.html
ErrorDocument 400 /errors/default.html
ErrorDocument 404 /errors/default.html
ErrorDocument 408 /errors/default.html
Order deny,allow
Allow from all
I shut down one of the proxied servers to test the error page and I see the following:
Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request.
If I use a text error message e.g "The server is currently off line" then I DO see that text displayed. If I reference an external web server to serve the page then I see the page served from that server. It is almost as if the Apache server is ONLY proxying requests and is unable to serve the local error pages.
I am guessing I need to add or change a virtual host entry to allow the Apache server to serve a local page (the error pages) but since the server is only referenced by IP in DNS I am not sure how to do that (it is using named hosts). I just assumed that the error pages would be properly served by Apache without additional configuration (beyond allowing the permissions on the folder with the error pages and referencing them in the ErrorDocument entries).
What did I miss? The setting up of custom error documents seemed simple but I can't serve them from the proxy itself.
Answer
Directly from Apache Docs
If you are using mod_proxy, you may wish to enable ProxyErrorOverride so that you can provide custom error messages on behalf of your Origin servers. If you don't enable ProxyErrorOverride, Apache httpd will not generate custom error documents for proxied content.
Also by using ErrorDocument 503 /errors/default.html
apache believes it is on the origin server, then issues its own error saying it can not find it as well.
No comments:
Post a Comment