apacheweb-servicestomcathttpd.confmod-jk

Redirect to maintenance.html from apache when tomcat down not working


I have apache setup in front of tomcat using mod_jk.

I have the below configured in my apache config file:

ErrorDocument 503 /maintenance.html

But my site does not redirect to this page if tomcat is down. If I replace with:

ErrorDocument 503 "foo"

as suggested in this link but it won't display foo. In both cases the page remains fairly blank and a banner pops up saying 503. If I open chrome tools and look on the network tab I get this:

enter image description here

where /current returns 503. The console tab shows 503 errors also. I am not a developer so handle the apache/tomcat config so I assume this problem needs fixing on my side - although could be wrong.

Thanks

edit: jkmount and errorducument entries below:

        JkMount /* loadbalancer
        JkMount /*.html loadbalancer
        JkUnMount / loadbalancer
        JkUnMount /index.html loadbalancer
        JkUnMount /assets/* loadbalancer
        JkUnMount /favicon.ico loadbalancer
        JkUnMount /icon/* loadbalancer
        JkUnMount /image/* loadbalancer
        JkUnMount /jar/*.jar loadbalancer
        JkUnMount /maintenance.html loadbalancer
        JkUnMount /pdf/*.pdf loadbalancer
        JkUnMount /policy/*.html loadbalancer
        JkUnMount /resources/* loadbalancer
        JkUnMount /zip/*.zip loadbalancer
        JkUnMount /*.css loadbalancer
        JkUnMount /*.jpg loadbalancer
        JkUnMount /*.js loadbalancer
        JkUnMount /*.ttf loadbalancer
        JkUnMount /*.woff loadbalancer
        JkUnMount /*.woff2 loadbalancer

        ErrorDocument 400 /error/
                # Unauthorized (i.e. HTTP authentication required)
        ErrorDocument 401 /error/
                # Forbidden
        ErrorDocument 403 /error/
                # Not Found
        ErrorDocument 404 /error/
                # Method Not Allowed
        ErrorDocument 405 /error/
                # Request URI Too Long
        ErrorDocument 414 /error/
                # Internal Server Error
        ErrorDocument 500 /error/
                # Not Implemented
        ErrorDocument 501 /error/
                # Service Not Available
        ErrorDocument 503 /maintenance.html
                # HTTP Version Not Supported
        ErrorDocument 510 /error/


Solution

  • Use below configuration and test.

    ErrorDocument 503 "foo"
    JkMount /* loadbalancer;use_server_errors=503
    JkMount /*.html loadbalancer;use_server_errors=503
    

    Use ErrorDocument before JkMount.