httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Evans <>
Subject Re: [users@httpd] mod_proxy: ProxyPassReverse ignored with ProxyPreserveHost?
Date Thu, 29 Mar 2012 16:22:07 GMT
On Thu, Mar 29, 2012 at 5:06 PM, Ron Van den Branden
<> wrote:
> Hi,
> Apologies for reposting that soon, but I've been thinking more about my
> question earlier today (see <>).
> So, rather than appearing impatient, I would like to rephrase that question
> more clearly. Basically, I have the impression that when  ProxyPreserveHost
> is switched on, ProxyPassReverse seems to be ignored.
> I'll briefly illustrate this observation. With following settings in
> httpd.conf:
>   ProxyPreserveHost off
>   ProxyPass /apps/      http://localhost:8082/
>   ProxyPassReverse /apps/    http://localhost:8082/
>   ProxyPassReverseCookiePath /apps/ /
> I can successfully proxy a request for <http://mydomain/apps/my_app/> to a
> Tomcat app at <http://localhost:8082/my_app/>. The ProxyPassReverse
> directive is working properly, as can be seen for requests that cause an
> internal redirection in the Tomcat app: <http://mydomain/apps/my_app/>
> correctly redirects (internally, via Tomcat) to
> <http://mydomain/apps/my_app/index.htm>.
> Yet, when switching on ProxyPreserveHost, internal redirects via Tomcat
> fail:
>   ProxyPreserveHost off
                         ^^^^ This should be "on" surely?
>   ProxyPass /apps/      http://localhost:8082/
>   ProxyPassReverse /apps/    http://localhost:8082/
>   ProxyPassReverseCookiePath /apps/ /
> A request for <http://mydomain/apps/my_app/> now redirects to
> <http://mydomain/my_app/index.htm>. Moreover, I have the impression anything
> can be entered for ProxyPassReverse without making any difference, e.g.:
>   ProxyPassReverse /apps/whatever/    http://localhost:8082/
> This doesn't affect the redirected URL whatsoever: it always is redirected
> to <http://mydomain/my_app/index.htm>. However, with ProxyPreserveHost
> switched off, above rule does redirect the original request to
> <http://mydomain/apps/whatever/my_app/index.htm>, which is what I'd expect.
> So, my question is: (how) can ProxyPassReverse be made to work in
> combination with ProxyPreserveHost?
> Kind regards,
> Ron

ProxyPassReverse has a *very* specific meaning. When it sees a header
value with the 2nd argument, it will replace it with the first
argument, and then use standard apache semantics to turn that into a
fully qualified URL. See UseCanonicalName for details on that.

So, what URL does your backend server generate? Does the Location
header, as seen by Apache, contain "http://localhost:8082/" when
ProxyPreserveHost is on, or does it contain something else?

The best way to debug reverse proxying is to run tcpdump on the proxy
server. That way, you can see the request as the reverse proxy sees
it, the request as the backend sees it, the raw response generated by
the backend and the processed response returned by the proxy. Without
seeing those things, we're probably just guessing.

If you can't use tcpdump, you will need to find some other way of
examining the "Location" header, eg a custom log format.



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

View raw message