tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: Running Tomcat Behind Apache HTTP Server
Date Tue, 11 Dec 2012 15:05:34 GMT
Dhruva Reddy wrote:
> Thanks, André, for your response.
> To give you a little more context, I needed to get this working as soon as
> possible, which I basically have.  Eventually, yes, I want the static
> content to be served by HTTPD, and the dynamic content to be served by
> Tomcat.  I did not want to deploy my application as ROOT, for reasons that,
> now that I think about it, don't really make sense.
> Anyway, your clue about the Directory directive was very helpful.  It
> turned out that my rewrite rules were being ignored.  I ended up with two
> rules, each on the condition that the request URI does not already contain
> the context.  I settled on the following (I'm running a Grails application
> which automagically recognizes the "html" extension):
> RewriteEngine On
> RewriteCond $0 !^/application/(.*)
> RewriteRule ^(.*)/$ ajp://localhost:8009/application/$1 [P]
> RewriteCond $0 !^/application/(.*)
> RewriteRule ^(.*)\.html$ ajp://localhost:8009/application$1.html [P]
> I know I still have some work to do, but at least I now have it basically
> working.
Good if it works. You did not originally specify which Apache-Tomcat connector you were 
using, so I took a potshot and guessed mod_jk, wrongly.

About the rules above :
- what happens when the URL already starts with "/application" ?
- the capture part in the RewriteCond above does not seem to be necessary, as you are 
testing for a "not match", so whatever is captured wouldn't be useful anyway.
- what happens when the Tomcat webapp returns a redirect ?
   Do you have some ProxyPassReverse directive for that ?

If I may comment, I believe that by forwarding "/" to tomcat's "/application", and 
afterward having other sub-sections of "/" not being forwarded to Tomcat, you are setting

yourself up for a lot of complications later on.
A lot of directive's effects in Apache are "inherited" from a top location to 
sub-locations by default, and you are going to find yourself obliged to countermand this 
inheritance in each sub-section. When you start mixing this with the relative paths that 
tomcat will generate for embedded images etc, and with (maybe) authentication and 
access-control, you'll be in for a treat.
If you are just starting this website's setup, it may be better to pause and think of a 
simpler layout.
Just my two cent.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message