I tried all I found at apache documentation and other sugestions found at stackoverflow and blogs.
When I add the folloowing line to any configuration file like /etc/apache2/apache2.conf
or /etc/apache2/conf.d/localized-error-pages
or /etc/apache2/httpd.conf
or /etc/apache2/sites-enabled/000-default
:
ErrorDocument 503 "This is an error msg"
or even an html message
ErrorDocument 503 "<h1> This is an error message </h1>
or an external url redirect ErrorDocument 503 http://www.google.com
it works.
But when I try an internal redirect like ErrorDocument 503 /ERROR_503.html
or ErrorDocument 503 /error/ERROR_503.html
I get the default message with last line:
Additionally, a 503 Service Temporarily Unavailable error was encountered while trying to use an ErrorDocument to handle the request.
I tried to put the html error page at the DocumentRoot var/www
, at var/www/error
.
Try to uncomment all the file /etc/apache2/conf.d/localized-error-pages
that sets all errors to custom pages with internationalization that are at /usr/share/apache2/error
.
And as the messages inside this files are the same as the default, the line
Additionally, a 503 Service Temporarily Unavailable error was encountered while trying to use an ErrorDocument to handle the request. is not shown anymore. But if I change the line
`ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var`
at the localized-error-pages file to a new html placed at the same page, the error is back
and the page is not shown. If I edit the file HTTP_SERVICE_UNAVAILABLE.html.var
nothing change at the browser message too.
Some more information: I'm using apache2 just to redirect all request on port 80 to tomcat at port 8089 via an worker. My configuration files are https://dl.dropboxusercontent.com/u/1105054/apache.zip
This took me way tooo long (partially due to spelling), but I thought I'd post my whole virtual host file since it might be useful.
You'll want to make sure you've specified a DocumentRoot, and that you do the ProxyPass /file.html !
before your main ProxyPass /
.
<VirtualHost *:443>
DocumentRoot /var/www/html
#ProxyPreserveHost On
<IfModule env_module>
# Fake SSL if Loadbalancer does SSL-Offload
SetEnvIf Front-End-Https "^on$" HTTPS=on
</IfModule>
SSLEngine on
SSLCertificateFile file
SSLCertificateKeyFile file
SSLCertificateChainFile file
ProxyPass /maintenance-message.html !
ProxyPass /maintance-message_files !
ProxyPass / "ajp://localhost:8009/"
ProxyPassReverse / "ajp://localhost:8009/"
ServerName server.something.com:443
ErrorDocument 503 /maintenance-message.html
</VirtualHost>
In my case I just added this ProxyPass line to my virtualserver config:
ProxyPass /serverError.html !
ErrorDocument 503 /serverError.html
That tells the proxy to go to the DocumentRoot and search for the error page.
Also you may find useful this answer: https://stackoverflow.com/a/13019667
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With