tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: mod_proxy_balancer anomaly Question
Date Thu, 15 Sep 2011 20:39:59 GMT
Shanti Suresh wrote:
> All,
> I am trying to understand some anomaly with mod_proxy and mod_proxy_balancer.  mod_proxy
works fine if the (reverse)Proxying is done to the local Tomcat Engine rather than going through
the balancer.  If it goes through the "balancer", then an extra "/" is added on 302 Redirects
after the hostname in URLs.  Adding "ProxyPreserveHost On" gets the proper 302 Redirects without
the extra "/".
> Short of reading source code, I was hoping someone can explain the:

Short answers :

> (1) purpose of "ProxyPreserveHost On"  ->  It is to pass the "Host" header from the
incoming request onto Tomcat

Yes. Because the default is that the front-end uses the hostname named in the ProxyPass 
statements, to replace the Host header received from the client.

> (2) Does "ProxyPreserveHost" have any implication on the "Location:" Header going out
in 302 responses?

It could have, indirectly, if the Tomcats have virtual hosts themselves.
E.g. : without the "ProxyPreserveHost", the "Host:" header sent to Tomcat will always be 
the one from the ProxyPass directive. So this will always be processed by the same virtual

host under Tomcat.
With the "ProxyPreserveHost", the "Host" header sent by the client will be left unchanged.
So it could potentially "select" another virtual host within Tomcat, and this virtual host

within Tomcat may return its 302 "Location" header differently than the virtual host 
mentioned above.
(I cannot think of a good reason why this could happen, but I suppose it could)

> (3) I thought the "ProxyPassReverse" directive was used for setting (rewriting) the "Location:"
header in the 302 responses.

It is. And it should only rewrite the hostname part of the value.

> (4) How does Tomcat work without "ProxyPreserveHost On" when requests don't go through
the balancer?

It will work fine, thank you. ;-)
at the simplest level, Tomcat doesn't know that it is being proxied to, or balanced, and 
does not know if in Apache httpd there is a ProxyPreserveHost or not.

It gets a HTTP request which contains a Host header.
It tries to match that name with one of its own <Host> tags.
If it finds a match, it dispatches the request to that <Host> within Tomcat.
If it does not find a match, it dispatches the request to its default host, which is the 
<Host> whose name is mentioned in the <Engine> tag.

What would help figuring this out, is
- a copy of the Tomcat's server.xml (edited, remove comments and sensitive info), pasted 
into your next message (this list strips most attachments)
- to know what really creates the 302 Redirect response within Tomcat (and its Location 

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

View raw message