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/13 23:11:08 UTC

apache Alias&Rewrites vs tomcat?

I'm trying to assertain just how Apache and Tomcat
interact regarding aliases and rewrites.

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.

If I have apache configured to apply an alias or a
rewrite rule to a reqest, I can tell from the logs
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 served up by Apache.

The problem is that Tomcat is not getting the
translated request, it is getting the original one. 
Since no file in that path actually exists, naturally
it returns a file not found error.

Could someone please tell me if this behavior is
correct or if this is a bug in mod_jk?  Should I be
using apj13? (I just noticed that the mod_jk.conf-auto
has the contexts mounted to apj12 so I'll try changing
that).

I seem to recall that JServ obeyed the results of
rewrites.  Should I try using tomcat with mod_jserv? 
'Would seem like walking backwards...

Please help clear this up so I don't spend too much
more time banging my head against this.

Thanks,

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/


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

Posted by Mel Martinez <me...@yahoo.com>.
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: ajp12 vs ajp13 & mod_jk.conf-auto

Posted by Filip Hanik <fi...@filip.net>.
> 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 :)

Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
filip@filip.net
www.filip.net
----- Original Message -----
From: "Mel Martinez" <me...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, February 13, 2001 3:11 PM
Subject: Re: ajp12 vs ajp13 & mod_jk.conf-auto


> Thanks, Filip.
>
> I'll try the changes you suggested.
>
> Now, if I could just get someone to tell me why apache
> Alias and Rewrites are not working with tomcat...
>
>
> Mel
>
>
>
> --- Filip Hanik <fi...@filip.net> wrote:
> > yes,
> > the JkMount command looks like this
> >
> > JkMount context workername
> >
> > so the autogenerated ajp12 is just the worker name
> > "ajp12"
> >
> > in the workers.properties file you can change the
> > protocol that the worker
> > is using.
> > the property file has the following format
> >
> > worker.<workername>.<propertyname>=<value>
> > worker.ajp12.port=8007
> > worker.ajp12.host=localhost
> > worker.ajp12.type=ajp13
> >
> > so just change the last line to use ajp13. now you
> > have to modify server.xml
> > to start a ajp13 connector on the port 8007 and
> > change the port for ajp12.
> >
> > the nice thing with the autogenerated file is that
> > your webapps can be
> > dynamic.
> > but if you need to do a lot of fancy stuff, you
> > should create your own file
> > for the mod_jk configuration.
> >
> > try playing around with it, and if you have a
> > specific problem let me know
> > and I can help you out.
> >
> > Filip
> >
> > ~
> > Namaste - I bow to the divine in you
> > ~
> > Filip Hanik
> > Software Architect
> > filip@filip.net
> > www.filip.net
> > ----- Original Message -----
> > From: "Mel Martinez" <me...@yahoo.com>
> > To: <to...@jakarta.apache.org>
> > Sent: Tuesday, February 13, 2001 2:32 PM
> > Subject: ajp12 vs ajp13 & mod_jk.conf-auto
> >
> >
> > > Question:
> > >
> > > what determines whether ajp12 or ajp13 will be
> > > specified for a jkmount statement in the
> > > auto-generated mod_jk.conf-auto file?
> > >
> > > I.E., it always generates statements like:
> > >
> > > JkMount /myapp/servlet/* ajp12
> > > JkMount /myapp/*.jsp ajp12
> > >
> > > I've even tried disabling all reference to ajp12
> > from
> > > server.xml and workers.properties but that had no
> > > effect.
> > >
> > > Is the only way to force the use of Ajp13 to
> > manually
> > > edit the mod_jk.conf file?
> > >
> > > Should I even be worrying about this?
> > >
> > > Thanks,
> > >
> > > 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
> > >
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, email:
> > tomcat-user-help@jakarta.apache.org
> >
>
>
> __________________________________________________
> 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
>
>


Urgent Problem with servler

Posted by "Carlos López M." <cl...@grupounika.com.mx>.
Hi im using Tomcat 3.2.2 Apache and mod_jk. Everithing works fine but when i
call a file I get this error

Method Not Allowed
The requested method POST is not allowed for the URL
/administracion/mail/UploadTest.java.


----------------------------------------------------------------------------
----

Apache/1.3.14 Server at www.domain.com Port 80

Could somebody help me


Re: ajp12 vs ajp13 & mod_jk.conf-auto

Posted by Mel Martinez <me...@yahoo.com>.
Thanks, Filip.

I'll try the changes you suggested.

Now, if I could just get someone to tell me why apache
Alias and Rewrites are not working with tomcat...


Mel



--- Filip Hanik <fi...@filip.net> wrote:
> yes,
> the JkMount command looks like this
> 
> JkMount context workername
> 
> so the autogenerated ajp12 is just the worker name
> "ajp12"
> 
> in the workers.properties file you can change the
> protocol that the worker
> is using.
> the property file has the following format
> 
> worker.<workername>.<propertyname>=<value>
> worker.ajp12.port=8007
> worker.ajp12.host=localhost
> worker.ajp12.type=ajp13
> 
> so just change the last line to use ajp13. now you
> have to modify server.xml
> to start a ajp13 connector on the port 8007 and
> change the port for ajp12.
> 
> the nice thing with the autogenerated file is that
> your webapps can be
> dynamic.
> but if you need to do a lot of fancy stuff, you
> should create your own file
> for the mod_jk configuration.
> 
> try playing around with it, and if you have a
> specific problem let me know
> and I can help you out.
> 
> Filip
> 
> ~
> Namaste - I bow to the divine in you
> ~
> Filip Hanik
> Software Architect
> filip@filip.net
> www.filip.net
> ----- Original Message -----
> From: "Mel Martinez" <me...@yahoo.com>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, February 13, 2001 2:32 PM
> Subject: ajp12 vs ajp13 & mod_jk.conf-auto
> 
> 
> > Question:
> >
> > what determines whether ajp12 or ajp13 will be
> > specified for a jkmount statement in the
> > auto-generated mod_jk.conf-auto file?
> >
> > I.E., it always generates statements like:
> >
> > JkMount /myapp/servlet/* ajp12
> > JkMount /myapp/*.jsp ajp12
> >
> > I've even tried disabling all reference to ajp12
> from
> > server.xml and workers.properties but that had no
> > effect.
> >
> > Is the only way to force the use of Ajp13 to
> manually
> > edit the mod_jk.conf file?
> >
> > Should I even be worrying about this?
> >
> > Thanks,
> >
> > 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
> >
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email:
> tomcat-user-help@jakarta.apache.org
> 


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

Re: ajp12 vs ajp13 & mod_jk.conf-auto

Posted by Filip Hanik <fi...@filip.net>.
yes,
the JkMount command looks like this

JkMount context workername

so the autogenerated ajp12 is just the worker name "ajp12"

in the workers.properties file you can change the protocol that the worker
is using.
the property file has the following format

worker.<workername>.<propertyname>=<value>
worker.ajp12.port=8007
worker.ajp12.host=localhost
worker.ajp12.type=ajp13

so just change the last line to use ajp13. now you have to modify server.xml
to start a ajp13 connector on the port 8007 and change the port for ajp12.

the nice thing with the autogenerated file is that your webapps can be
dynamic.
but if you need to do a lot of fancy stuff, you should create your own file
for the mod_jk configuration.

try playing around with it, and if you have a specific problem let me know
and I can help you out.

Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
filip@filip.net
www.filip.net
----- Original Message -----
From: "Mel Martinez" <me...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, February 13, 2001 2:32 PM
Subject: ajp12 vs ajp13 & mod_jk.conf-auto


> Question:
>
> what determines whether ajp12 or ajp13 will be
> specified for a jkmount statement in the
> auto-generated mod_jk.conf-auto file?
>
> I.E., it always generates statements like:
>
> JkMount /myapp/servlet/* ajp12
> JkMount /myapp/*.jsp ajp12
>
> I've even tried disabling all reference to ajp12 from
> server.xml and workers.properties but that had no
> effect.
>
> Is the only way to force the use of Ajp13 to manually
> edit the mod_jk.conf file?
>
> Should I even be worrying about this?
>
> Thanks,
>
> 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
>
>


ajp12 vs ajp13 & mod_jk.conf-auto

Posted by Mel Martinez <me...@yahoo.com>.
Question:

what determines whether ajp12 or ajp13 will be
specified for a jkmount statement in the
auto-generated mod_jk.conf-auto file?

I.E., it always generates statements like:

JkMount /myapp/servlet/* ajp12
JkMount /myapp/*.jsp ajp12

I've even tried disabling all reference to ajp12 from
server.xml and workers.properties but that had no
effect.

Is the only way to force the use of Ajp13 to manually
edit the mod_jk.conf file?

Should I even be worrying about this?

Thanks,

mel

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