0

I've apache2 and tomcat6 both running on port 80 with mod_jk setup on ubutnu servers. I had to setup an error document 503 ErrorDocument 503 /maintenance.html in the apache configuration and somehow I managed to get it work and the error page is server by apache when tomcat is stopped. Developers created a good looking error page(an html page which calls css and jpg) and I'm asked to get this page served by apache when tomcat is down. When I tried with JkUnMount /*.css in the virtual hosting, the actual tomcat jsp pages didn't work properly(lost the format) as the tomcat applications uses jsp, css, js, jpg and so on. I'm trying if it is possible to get .css and .jpg served by both apache and tomcat so that when the tomcat is down I'll get css and jpg serverd by apache and the proper error document is served. Anyone has any technique?

Here is my apache2 configuration:

vim /etc/apache2/apache2.conf

Alias / /var/www/
ErrorDocument 503 /maintenance.html
ErrorDocument 404 /maintenance.html
JkMount / myworker
JkMount /* myworker
JkMount /*.jsp myworker
JkUnMount /*.html myworker


<VirtualHost *:80>
ServerName station1.mydomain.com
DocumentRoot /usr/share/tomcat/webapps/myapps1
        JkMount /* myworker
        JkUnMount /*.html myworker
</VirtualHost>


<VirtualHost *:80>
ServerName station2.mydomain.com
DocumentRoot /usr/share/tomcat/webapps/myapps2
        JkMount /* myworker
    JkMount /*.html myworker
</VirtualHost>

Simply what I'm trying to do is, css and jpg should be served by apache when tomcat is stopped and when tomcat is started it should be served by tomcat not by apache.

user53864
  • 1,653
  • 8
  • 36
  • 66

3 Answers3

1

If your maintenance page is not too complex I would suggest inlining the stylesheets into the document. This way, you will not have to bother with a complicated ruleset as you mentioned above and are still able to server a well-styled maintenance page. Of course this will not necessarily solve the problem with images, though.

Axel Knauf
  • 1,600
  • 1
  • 10
  • 12
0

Could you not also be a bit more clever with your JkMounts. So (removed some lines for clarity):-

Alias / /var/www/
ErrorDocument 503 /maintenance/maintenance.html
JkMount / myworker
JkMount /* myworker
JkUnmount /maintenance/* myworker

<VirtualHost *:80>
    ServerName station1.mydomain.com
    DocumentRoot /usr/share/tomcat/webapps/myapps1
    JkMount /* myworker 
    JkUnmount /maintenance/* myworker
</VirtualHost>

Then you can statically link through to the common css and jpg's from inside the mainentance folder.

Decado
  • 1,949
  • 11
  • 17
  • I tried this already, creating a folder `abc` inside /var/www/ and placing `maintenance.html` into it and /abc/maintenance.html as error document and unmount the error document but css & jpg didn't work. Now I'm using CDN servers for this small error page. A small change to your VirtualHost of your solution that you forgot workername `myworker` in jkunmount line – user53864 Feb 23 '11 at 11:28
0

Put all your custom errors in a subdirectory and then use the no-jk environment variable to bypass mod_jk for that subdirectory like:

SetEnvIfRequest_URI "/errors/*" no-jk
JkMount / myworker
JkMount /* myworker
JkMount /*.jsp myworker

Then, you don't need to be bothered with the JkUnMount directives.

mahnsc
  • 1,776
  • 13
  • 11