apache tomcat 503 custom error page

14,797

From the apache documentation,

URLs can begin with a slash (/) for local web-paths (relative to the 
DocumentRoot), or be a full URL which the client can resolve.

I guess ErrorDocument 503 /maintenance.html should work.

Share:
14,797
user465465
Author by

user465465

Updated on June 30, 2022

Comments

  • user465465
    user465465 almost 2 years

    I have apache2 and tomcat6(not installed from apt repository, manually downloaded and installed) running on port 80 with mod_jk setup. The jsp servlet pages are accessed pointing the browser to http://myapp.mydomain.com/ (virtual hosting is done in tomcat(server.xml) and in apache). I'm trying to redirect tomcat's error page 503 to custom error page when tomcat is down(pkill -9 java or /etc/init.d/tomcat stop) during deployment.

    My apache's Document Root is /var/www/ so I place below entry in apache2.conf file

    ErrorDocument 503 maintenance.html and created a file maintenance.html under /var/www. When I tested stopping the tomcat and I got the page redirected to maintenance.html without having the url changed but the actual page is not displayed, instead the file name maintenance.html is displayed on the browser. Could any one help me properly configuring apache that redirects to proper maintenance.html page when tomcat is down?.

  • user465465
    user465465 over 13 years
    In the /etc/apache2/sites-enabled/000-defaults file the DocumentRoot is /var/www/ instead /var/www. If I use /maintenance.html instead maintenance.html I'll get the same Server Temporarly Unavailable error page.
  • user465465
    user465465 over 13 years
    Like server-ip/maintenance.html works and I can add ErrorDocument 503 http://server-ip/maintenance.html in the apache config file and this works but the page stays in the maintenance page and the user again have to point the url to myapp.mydomain.com after the tomcat is up.
  • Raghuram
    Raghuram over 13 years
    From apache docs (httpd.apache.org/docs/2.0/mod/core.html#documentroot), The DocumentRoot should be specified without a trailing slash. Good luck to you!
  • Raghuram
    Raghuram over 13 years
    maintenance.html can contain a clickable link to your app or a periodic meta refresh to it.
  • user465465
    user465465 over 13 years
    It's just a normal html program and there is nothing like that as it is created by me.