You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shanti Suresh <sh...@umich.edu> on 2011/09/15 17:18:58 UTC

mod_proxy_balancer anomaly Question

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:
(1) purpose of "ProxyPreserveHost On"  ->  It is to pass the "Host" header from the incoming request onto Tomcat
(2) Does "ProxyPreserveHost" have any implication on the "Location:" Header going out in 302 responses?
(3) I thought the "ProxyPassReverse" directive was used for setting (rewriting) the "Location:" header in the 302 responses.
(4) How does Tomcat work without "ProxyPreserveHost On" when requests don't go through the balancer?

Thanks!

            -Shanti

--
Shanti Suresh
shanti@umich.edu
http://lsa.umich.edu/cms






Re: mod_proxy_balancer anomaly Question

Posted by Pid <pi...@pidster.com>.
On 15/09/2011 16:18, 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:
> (1) purpose of "ProxyPreserveHost On"  ->  It is to pass the "Host" header from the incoming request onto Tomcat
> (2) Does "ProxyPreserveHost" have any implication on the "Location:" Header going out in 302 responses?
> (3) I thought the "ProxyPassReverse" directive was used for setting (rewriting) the "Location:" header in the 302 responses.
> (4) How does Tomcat work without "ProxyPreserveHost On" when requests don't go through the balancer?

Please start an entirely new email thread.

Replying to an existing thread, just editing subject & body, is called
thread-hijacking and makes your message appear in the middle of another
conversation in threaded mail readers.


p




Re: mod_proxy_balancer anomaly Question

Posted by André Warnier <aw...@ice-sa.com>.
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. ;-)
Seriously,
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 
header)





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org