You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mel Martinez <me...@yahoo.com> on 2001/02/15 20:53:34 UTC

Aliases/Rewrites (was: ajp12 vs ajp13 & mod_jk.conf-auto

Filip,

--- Filip Hanik <fi...@filip.net> wrote:
> > Now, if I could just get someone to tell me why
> apache
> > Alias and Rewrites are not working with tomcat...
> 
> tell us what you are trying to do and send us some
> sample config files and
> how your environment is setup. is becomes much
> easier than to answer the
> question above, because alias works very well for me
> :)
> 

Well, actually, I've twice posted detailed
descriptions of what I'm trying to accomplish on this
topic and gotten zero replies, but here goes another
attempt...

I'm using Apache 1.3.14 and tomcat 3.2.1 with
mod_jk.c.  I don't know if the latter is the 'latest'
version of mod_jk.c - I grabbed it from the tomcat
download site two weeks ago.  I am running this on
WinNT using downloaded binary versions of the relevant
software.

I have setup my application ("myapp") as a directory
inside the webapps/ directory, complete with WEB-INF
subdirectory and such.

I have apache configured to apply an alias or a
rewrite rule to a reqest:
#--------------
<IfModule !mod_rewrite.c>
LoadModule rewrite_module
n:/opt/local/apache/modules/ApacheModuleRewrite.dll
</IfModule>

RewriteEngine On
RewriteLog log/apache_logs/rewrites.log
RewriteLogLevel 9
RewriteOptions inherit
RewriteRule ^/myapp/(.*)/common/(.*) /myapp/common/$2
#-------------


I can tell from the rewrites.log that it is indeed
getting applied:

 (2) init rewrite engine with requested uri
/myapp/folder1/common/mypage.jsp
 (3) applying pattern '^/myapp/(.*)/common/(.*)' to
uri '/myapp/folder1/common/mypage.jsp'
 (2) rewrite /myapp/folder1/common/mypage.jsp ->
/myapp/common/mypage.jsp
 (2) local path result: /myapp/common/mypage.jsp
 (1) go-ahead with /myapp/common/mypage.jsp [OK]

The idea here is simple: the request

/myapp/folder1/common/mypage.jsp

should result in a request for

/myapp/common/mypage.jsp

The rewrite rule works great.  This works great for
static stuff (i.e. html) served up by Apache. 

The *problem* is that Tomcat is not getting the
translated request, it is getting the original one:

/myapp/folder1/common/mypage.jsp
 
Since no file in that path actually exists, naturally
it returns a file not found error.  Tomcat DOES
happily find, compile and execute requests for
servlets and jsp pages that are in paths that do exist
such as

/myapp/folder1/myother.jsp

I have apache configured to send requests to tomcat
via ajp13 by including mod_jk.conf-auto just after the
above rewrite rule:

# include configuration for tomcat servlet engine:
#
Include n:/opt/demo/conf/mod_jk.conf-auto
#

I've configured server.xml very minimally, no custom
contexts or anything.  About the only thing changed
here is I've enabled ajp13 and then setup
workers.properties to map requests to it.  I doubt any
of this is relevant because I see the exact same
behavior even with 'raw' server.xml and
worker.properties files.

Note that I get the same behavior if I use an Alias
instead of a rewrite:

#--------------
Alias (.*)/myapp/(.*)/common/(.*) $1/myapp/common/$3
#--------------

This rewrites static requests served by Apache, but
just like with rewrites, gets ignored by tomcat.

That's pretty much it.

Any suggestions as to what is (or is not) going on?

Basically, what I want to happen is that, after a
rewrite rule has been applied, that Tomcat should be
processing the modified URL, not the original.

Thanks in advance for any help!

Mel


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Re: Aliases/Rewrites (was: ajp12 vs ajp13 & mod_jk.conf-auto

Posted by Mel Martinez <me...@yahoo.com>.
--- Jan Labanowski <jk...@osc.edu> wrote:
> It is my (and others) experience that mod_jk has to
> be loaded BEFORE
> mod_rewrite for it to act responsibly. In your case
> the mod_rewrite is 
> linked statically, i.e., loaded before mod_jk. I
> would suggest to
> make both mod_jk and mod_rewrite DSO, and load/add
> module mod_jk before
> mod_rewrite. Remember to comment out the 
>   # LoadModule jk_module libexec/mod_jk.so      
> in mod_jk.conf
> 

Ya know, I'm almost 100% positive I tried this before
to no affect, but being in a mad dash to fix things, I
may spoiled that test by simultaneously changing
something else.  At any rate, with mod_jk loaded
before mod_rewrite (in my case, I am able to simply
perform the include of mod_jk.conf-auto before I do
any rewrites) it seems to work.  I also had a stupid
syntax error in my rewrite expression so maybe that
was it.

Amazin' how much time one can spend fixin' somethin'
that ain't broke...

Mel


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Re: Aliases/Rewrites (was: ajp12 vs ajp13 & mod_jk.conf-auto

Posted by Jan Labanowski <jk...@osc.edu>.
It is my (and others) experience that mod_jk has to be loaded BEFORE
mod_rewrite for it to act responsibly. In your case the mod_rewrite is 
linked statically, i.e., loaded before mod_jk. I would suggest to
make both mod_jk and mod_rewrite DSO, and load/add module mod_jk before
mod_rewrite. Remember to comment out the 
  # LoadModule jk_module libexec/mod_jk.so      
in mod_jk.conf

Jan


On Thu, 15 Feb 2001, Mel Martinez wrote:

> Filip,
> 
> --- Filip Hanik <fi...@filip.net> wrote:
> > > Now, if I could just get someone to tell me why
> > apache
> > > Alias and Rewrites are not working with tomcat...
> > 
> > tell us what you are trying to do and send us some
> > sample config files and
> > how your environment is setup. is becomes much
> > easier than to answer the
> > question above, because alias works very well for me
> > :)
> > 
> 
> Well, actually, I've twice posted detailed
> descriptions of what I'm trying to accomplish on this
> topic and gotten zero replies, but here goes another
> attempt...
> 
> I'm using Apache 1.3.14 and tomcat 3.2.1 with
> mod_jk.c.  I don't know if the latter is the 'latest'
> version of mod_jk.c - I grabbed it from the tomcat
> download site two weeks ago.  I am running this on
> WinNT using downloaded binary versions of the relevant
> software.
> 
> I have setup my application ("myapp") as a directory
> inside the webapps/ directory, complete with WEB-INF
> subdirectory and such.
> 
> I have apache configured to apply an alias or a
> rewrite rule to a reqest:
> #--------------
> <IfModule !mod_rewrite.c>
> LoadModule rewrite_module
> n:/opt/local/apache/modules/ApacheModuleRewrite.dll
> </IfModule>
> 
> RewriteEngine On
> RewriteLog log/apache_logs/rewrites.log
> RewriteLogLevel 9
> RewriteOptions inherit
> RewriteRule ^/myapp/(.*)/common/(.*) /myapp/common/$2
> #-------------
> 
> 
> I can tell from the rewrites.log that it is indeed
> getting applied:
> 
>  (2) init rewrite engine with requested uri
> /myapp/folder1/common/mypage.jsp
>  (3) applying pattern '^/myapp/(.*)/common/(.*)' to
> uri '/myapp/folder1/common/mypage.jsp'
>  (2) rewrite /myapp/folder1/common/mypage.jsp ->
> /myapp/common/mypage.jsp
>  (2) local path result: /myapp/common/mypage.jsp
>  (1) go-ahead with /myapp/common/mypage.jsp [OK]
> 
> The idea here is simple: the request
> 
> /myapp/folder1/common/mypage.jsp
> 
> should result in a request for
> 
> /myapp/common/mypage.jsp
> 
> The rewrite rule works great.  This works great for
> static stuff (i.e. html) served up by Apache. 
> 
> The *problem* is that Tomcat is not getting the
> translated request, it is getting the original one:
> 
> /myapp/folder1/common/mypage.jsp
>  
> Since no file in that path actually exists, naturally
> it returns a file not found error.  Tomcat DOES
> happily find, compile and execute requests for
> servlets and jsp pages that are in paths that do exist
> such as
> 
> /myapp/folder1/myother.jsp
> 
> I have apache configured to send requests to tomcat
> via ajp13 by including mod_jk.conf-auto just after the
> above rewrite rule:
> 
> # include configuration for tomcat servlet engine:
> #
> Include n:/opt/demo/conf/mod_jk.conf-auto
> #
> 
> I've configured server.xml very minimally, no custom
> contexts or anything.  About the only thing changed
> here is I've enabled ajp13 and then setup
> workers.properties to map requests to it.  I doubt any
> of this is relevant because I see the exact same
> behavior even with 'raw' server.xml and
> worker.properties files.
> 
> Note that I get the same behavior if I use an Alias
> instead of a rewrite:
> 
> #--------------
> Alias (.*)/myapp/(.*)/common/(.*) $1/myapp/common/$3
> #--------------
> 
> This rewrites static requests served by Apache, but
> just like with rewrites, gets ignored by tomcat.
> 
> That's pretty much it.
> 
> Any suggestions as to what is (or is not) going on?
> 
> Basically, what I want to happen is that, after a
> rewrite rule has been applied, that Tomcat should be
> processing the modified URL, not the original.
> 
> Thanks in advance for any help!
> 
> Mel
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35 
> a year!  http://personal.mail.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
> 

Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
Ohio Supercomputer Center    |    Internet: jkl@osc.edu 
1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
Columbus, OH 43212-1163      |    http://www.osc.edu/