tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Gastel" <>
Subject RE: Apache proxy question
Date Thu, 30 Oct 2003 21:47:54 GMT
Hi William,

I use apache with a reverse proxy setup to tomcat.  This is primarily so I
can use a hardware load balancer (it understands http, not ajp13 etc etc)

Hopefully this answers your questions:

Basically I use mod_rewrite to rewrite a url and send it off to tomcat:

ProxyPassReverse /servlet  http://mytomcat:8880/myapp/servlet/
RewriteRule ^/servlet/(.*) http://mytomcat:8880/myapp/servlet/$1 [p]

The two rules above will send /servlet/ requests off to tomcat, and also
handle rewriting redirects generated by tomcat so that it is translated from
the /myapp/servlet to /servlet url path.  It's important that you have the
appropriate proxy settings in the tomcat http connector.

ProxyPreserveHost On

The "ProxyPreserveHost On" tells apache to pass through the "Host:" part to
the http request, instead of changing it to the proxies hostname.  All you
need to do is set up the same virtual hosts in tomcat and apache.

Couple of other things of note:
1) once you go through a proxy the ip address returned by
req.getRemoteAddr() is the proxies ip address.  You have to get the client
ip address from the "x-forwarded-for" header.
2) you can add a "Header unset Server" directive if you wrap everything in a
<Location> block.  Apache will remove the "Server:  Tomcat blah blah" from
tomcat's response and replace it with whatever you have apache set to
respond with...this makes it slightly less obvious you are running tomcat
behind the scenes.

Hope this helps!

-----Original Message-----
From: William Bondy []
Sent: Monday, October 27, 2003 8:39 AM
To: ''
Subject: Apache proxy question

I'm a newbie to apache/tomcat intergration. A couple of questions:

1) Can apache run in a proxy mode and still forward requests to Tomcat?

2) If it can, does apache send requests to Tomcat as if Tomcat is part of
the proxy server (ie. absolute URL) or an origin server (ie. relative URL),
I would expect that Tomcat would be part of the proxy server and hence
receive abolute URLs.

3) How does URL mapping in Tomcat work when a host name is provided in an
absolute URL.


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

View raw message