OK this question is asked all the time I know: "What's the best way to connect Tomcat through apache". But I still haven't found a definitive answer and maybe there isn't one, but I'm just looking for a viable, high performance setup. So much of the documentation I've read references articles from 2005 and older. I'm looking for a 2010 solution :)
I have a current setup (not created by me) that uses mod_rewrite to rewrite all traffic from apache to tomcat using:
RewriteRule ^(.*) ajp://localhost:8009$1 [P,L]
We have one app as the ROOT app in tomcat. So right now I'm using mod_rewrite to send requests over ajp (is this different from mod_proxy_ajp??). Are there any reasons why this might be less than satisfactory?
Also, I'm looking to get Apache to serve up static assets to take some load off Tomcat, also so I can easily use mod_expires/deflate etc... I'm unsure of how to do this.
I have an 'assets' (ie. js/css) and 'images' folder in the webroot (same directory as WEB-INF) so I'm assuming I need some sort of match on /images
and /assets
that says "don't pass this on to Tomcat" ??
Any help/suggestions/comments on the current setup are greatly appreciated.
btw i'm using:
apache2 - 2.2.9-10
Tomcat - 5.5.29
If you would like say, things under the path http://localhost/static/* to be served up from Apache, then you can set a RewriteCond before your rule to capture everything that doesn't have the URI as /static/* and forward on the Tomcat via AJP, essentially leaving /static/* alone to be served out from DocRoot or an Alias, etc.
For example:
The P in your rewriterule is Proxy