Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
Subject: Re: jk_mod and binding tomcat 's root to an apache directory

Subject: Re: jk_mod and binding tomcat 's root to an apache directory

2007-11-04       - By Rainer Jung

 Back
Hi,

actually there are two things to discuss here:

1) How to express rules which requests should be forwarded
2) Rewriting URLs

and finally, how does one combine the two.

Concerning 1)
-- ---- -----

First the case, where you don't want to rewrite the URL, e.g. the
browser really asks for /servlet-examples-URLs directly.

Then you would simply use

JkMount /servlet-examples/* myworker

(and myworker is a placeholder for the name of your worker).

In case you want to also forward the exact URL /servlet-examples, but
e.g. not /servlet-examples2, you can combine

JkMount /servlet-examples/* myworker
JkMount /servlet-examples/ myworker

into one line:

JkMount /servlet-examples|/* myworker

Concerning 2)
-- ---- -----

You can rewrite URLs via mod_rewrite. For your example a very basic
configuration (based on httpd 2.2) would be

LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteRule /tomcat/(.*) /servlet-examples/$1

Since you want to combine the rewriting with mod_jk, i.e. mod_jk should
forward the rewritten URL, and not the original URL, you need to add the
PT flag to the rewrite rule (see mod_rewrite docs in httpd docs).

RewriteRule /tomcat/(.*) /servlet-examples/$1 [PT]

Now this will mean, that also the JkMount will be matched against the
rewritten rule.

In most cases it will be more adequate to really add JkMounts like

JkMount /servlet-examples|/* myworker

because you want to manage forwardingby the actual contexts/webapps
deployed on the backends. If you *really* want to forward based on the
original URL, you can do this in httpd 2.2 with another extension of the
rewrite rules:

RewriteRule /tomcat/(.*) /servlet-examples/$1
[E=JK_WORKER_NAME:myworker,H=jakarta-servlet,PT]

This will set the handler to jakarta-servlet, which activates JK
forwarding for this request even without any matching JkMount, and the
forwarding takes the name of the worker out of the environment variable
JK_WORKER_NAME, which we set to myworker.

Even without rewriting, the setup is zero-admin, as long as there is no
new context deployed. The exact servlets do not matter. Whenever you add
another webapp, e.g. jsp-examples, you need to add another config line,
either when using JkMount and doing no URL rewriting, or when using
Rewriting.

You can though deploy your webapps not on the top level directory, but
instead into a sub directory (using a path, that contains more than one
URL directory component), e.g. /tomcat/servlet-examples etc. directly on
your tomcat, and then JkMount /tomcat/*. That'll be true zero-admin.

I hope that's understandable :)

Regards,

Rainer

Shug Boabby schrieb:
> Hello everyone,
>
> There does not appear to be a separate list for mod_jk discussions... so
> I assume this is the most relevant place to ask questions. Please let me
> know if there is somewhere more specific for me to bring this.
>
> I have mod_jk up and running with Apache 2 and Tomcat 5.5. However, it
> seems that every single servlet must be mapped by hand in the apache
> config files! This seems like a lot of work to me. What I'd really like
> to do would be to map my server's "/tomcat" path to redirect any
> requests to Tomcat's root. e.g. a request coming in to my server at
> /tomcat/servlet-examples would be re-routed to Tomcat's /servlet-examples
>
> Such a setup would mean zero admin in the Apache-Tomcat bridge when new
> servlets are added. As they are added to Tomcat, they immediately become
> accessible in Apache's /tomcat/ directory. Is it possible to set it up
> this way? It seems a very sensible way to do things.
>
> Shug

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.