You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Deacon Marcus <de...@wwtech.pl> on 2001/12/29 12:41:32 UTC

Tomcat "chaining" ?

Hi,
It's pretty common to have configuration like one Apache + multiple Tomcats
for the purpose of separating JVMs for webapps / webapp sets. Would it be
possible to set up one Tomcat to forward all requests to a specific
webapp/vhost to another Tomcat so the second Tomcat could be restarted
without affecting other webapps/vhosts? Sort of semi-separated dev./prod.
configuration. Tomcat 4.0, JDK 1.4, possible incompatibility with other
jsp/servlet enabled servers is not an issue. I'm guessing it's possible or
even trivial with a servlet or valve on "master" Tomcat, but there could be
a number of problems with implementing "slave" connector. It would be easy
to just tunnel HTTP requests once "host: " header is known, but here's the
first problem - request.getRemoteAddr would return "master" Tomcat's IP. Any
suggestions/hints?

Greetings,
     deacon Marcus

~~~~~
HELP STARVING JAVA PROGRAMMER: If you need cheap and reliable JSP hosting,
please contact deacon_marcus@wwtech.pl (from 12$/m for 50mb WWW + 20mb mail)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat "chaining" ?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Sat, 29 Dec 2001, Deacon Marcus wrote:

> Date: Sat, 29 Dec 2001 12:41:32 +0100
> From: Deacon Marcus <de...@wwtech.pl>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: tomcat-dev@jakarta.apache.org
> Subject: Tomcat "chaining" ?
>
> Hi,
> It's pretty common to have configuration like one Apache + multiple Tomcats
> for the purpose of separating JVMs for webapps / webapp sets. Would it be
> possible to set up one Tomcat to forward all requests to a specific
> webapp/vhost to another Tomcat so the second Tomcat could be restarted
> without affecting other webapps/vhosts?

It's certainly feasible to do this kind of thing.  I would think of it as
proxying more than chaining -- but it's essentially what a web connector
does when it decides to forward a request to Tomcat.

If I ever have enough spare time, this is on my list of things to
experiment with -- it's probably only a couple hundred lines in a single
servlet to do simple load balancing with session affinity the way that
MOD_JK does it.  Add a little more if you want to do fancy stuff (like
using SSL tunnelling through a firewall between the "master" Tomcat (in
the DMZ) and the "slave" Tomcats (behind the firewall).

> Sort of semi-separated dev./prod.
> configuration. Tomcat 4.0, JDK 1.4, possible incompatibility with other
> jsp/servlet enabled servers is not an issue. I'm guessing it's possible or
> even trivial with a servlet or valve on "master" Tomcat, but there could be
> a number of problems with implementing "slave" connector. It would be easy
> to just tunnel HTTP requests once "host: " header is known, but here's the
> first problem - request.getRemoteAddr would return "master" Tomcat's IP. Any
> suggestions/hints?
>

You've got the same issue in any server environment running behind a
firewall.  For cases that don't care about the "real" remote IP address,
we can just ignore it.  For cases that do care, it would be
straightforward to have the proxy servlet add a custom HTTP header as the
request is passed on, and modify the receiving Tomcat's HTTP connector to
use this to set the values returned by getRemoteAddr(), getRemoteHost(),
and getRemotePort().

Other than watching for the special header, I don't see why we can't just
use the standard HTTP connector on the "slave" Tomcat(s) for this.

> Greetings,
>      deacon Marcus
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>