We have a slightly complex Apache 2.2 setup in front of a Tomcat 6.0 instance. The main Tomcat webapp is deployed in:
/opt/tomcat/webapps/ROOT
But we also have static content that we update semi-regularly. We didn't want to force a new build and deploy of the webapp, so that's stored separately in folders like:
/opt/tomcat/webapps/css
/opt/tomcat/webapps/foo
/opt/tomcat/webapps/bar
To handle this from Apache, we use mod_rewrite and rules look something like the following:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/css/(.*)$ - [L]
RewriteCond ROOT/%{REQUEST_FILENAME} -f
RewriteRule ^/css/(.*)$ ROOT/$1 [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)\.(jpg|png|html|js)$ - [L]
RewriteCond ROOT/%{REQUEST_FILENAME} -f
RewriteRule ^(.*)\.(jpg|png|html|js)$ - [L]
RewriteRule ^/(.*)$ http://localhost:8080/$1 [P,L]
ProxyPassReverse / http://localhost:8080/
I now think I might want to start using mod_jk and I have two questions:
- Is it even worth using mod_jk? I don't need load balancing.
- Is it even possible to handle the cases I outlined where the static content is referenced as "http://www.example.com/css/foo.css", but we don't know if it's located in the Tomcat webapp or in one of the static folders.
Why are you thinking of using mod_jk?
If it's to use ajp communication, to speed up transfer to tomcat why not look at mod_proxy_ajp?
You'd just change the tomcat rewriute rule to:-