Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Has anyone any idea? –  user53864 Feb 3 '11 at 9:55
    
Any other idea? –  user53864 Feb 7 '11 at 12:54

3 Answers 3

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.

share|improve this answer
    
Atleast you have said something +1 for this –  user53864 Feb 2 '11 at 14:25
    
Sorry it's +10. Any more info. –  user53864 Feb 4 '11 at 4:49
    
If you don't want to inline, you have have the css, js, and images load from error.mydomain.com –  becomingwisest Feb 23 '11 at 8:02

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.

share|improve this answer
    
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

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.