You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Spil Oss <sp...@googlemail.com> on 2006/09/15 15:41:51 UTC

[users@httpd] mod_proxy and mod_headers

I'm trying to modify the "Host" request header for a URL that is
subject to proxying, but that doesn't seem to work. Setting
ProxyPreserveHost On does work, but breaks other parts of the
configuration.

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule headers_module modules/mod_headers.so

RewriteEngine On

RequestHeader set Host www.somehost.com

RewriteRule /cd4(.*) http://www.backend1:8080/cd4$1 [P]

result between Apache en backend
GET /cd4/survey.htm HTTP/1.1\r\n
Host: www.backend.com:8080\r\n

Is there something that I'm overlooking? (processing order of modules?)

Kind Regards,

Spil Oss

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy and mod_headers

Posted by Spil Oss <sp...@googlemail.com>.
Finally got the setup to work.
For some backends I thought I needed ProxyPreserveHost On.
Investigating further I found a way for the server to construct pages
with absolute URLs to the external server-name.

On 15/09/06, Joshua Slive <jo...@slive.ca> wrote:
> On 9/15/06, Spil Oss <sp...@googlemail.com> wrote:
> > The proxy is addressed with https and some of the backends are http.
> > For the backends that do correct location headers and serve http,
> > ProxyPreserveHost sends the host to the backend with http-protocol,
> > the backend returns redirect location:
> > http://www.somehost.com/somepath which isn't available by http. Using
> > ProxyPassReverse for these locations doesn't work because the location
> > does not contain the proxy's address but the external address.
>
> I haven't thought it through completely, but I'd guess you could use
> ProxyPassReverse on that, as in
> ProxyPassReverse / http://www.somehost.com/
> even if somehost.com is the name of the proxy.
>
> Joshua.
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy and mod_headers

Posted by Joshua Slive <jo...@slive.ca>.
On 9/15/06, Spil Oss <sp...@googlemail.com> wrote:
> The proxy is addressed with https and some of the backends are http.
> For the backends that do correct location headers and serve http,
> ProxyPreserveHost sends the host to the backend with http-protocol,
> the backend returns redirect location:
> http://www.somehost.com/somepath which isn't available by http. Using
> ProxyPassReverse for these locations doesn't work because the location
> does not contain the proxy's address but the external address.

I haven't thought it through completely, but I'd guess you could use
ProxyPassReverse on that, as in
ProxyPassReverse / http://www.somehost.com/
even if somehost.com is the name of the proxy.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy and mod_headers

Posted by Spil Oss <sp...@googlemail.com>.
The proxy is addressed with https and some of the backends are http.
For the backends that do correct location headers and serve http,
ProxyPreserveHost sends the host to the backend with http-protocol,
the backend returns redirect location:
http://www.somehost.com/somepath which isn't available by http. Using
ProxyPassReverse for these locations doesn't work because the location
does not contain the proxy's address but the external address.

Kind regards,

Spil

On 15/09/06, Joshua Slive <jo...@slive.ca> wrote:
> On 9/15/06, Spil Oss <sp...@googlemail.com> wrote:
> > I'm trying to modify the "Host" request header for a URL that is
> > subject to proxying, but that doesn't seem to work. Setting
> > ProxyPreserveHost On does work, but breaks other parts of the
> > configuration.
> >
> > LoadModule rewrite_module modules/mod_rewrite.so
> > LoadModule headers_module modules/mod_headers.so
> >
> > RewriteEngine On
> >
> > RequestHeader set Host www.somehost.com
> >
> > RewriteRule /cd4(.*) http://www.backend1:8080/cd4$1 [P]
> >
> > result between Apache en backend
> > GET /cd4/survey.htm HTTP/1.1\r\n
> > Host: www.backend.com:8080\r\n
> >
> > Is there something that I'm overlooking? (processing order of modules?)
>
> I don't believe Host can be overridden.  It is set just before the request.
> Why doesn't ProxyPreserveHost work for you?  The alternative is to
> monkey with name resolution on the reverse proxy so that
> www.somehost.com maps to the IP of www.backend1 and then use
> www.somehost.com in your RewriteRule.
>
> Joshua.
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy and mod_headers

Posted by Joshua Slive <jo...@slive.ca>.
On 9/15/06, Spil Oss <sp...@googlemail.com> wrote:
> I'm trying to modify the "Host" request header for a URL that is
> subject to proxying, but that doesn't seem to work. Setting
> ProxyPreserveHost On does work, but breaks other parts of the
> configuration.
>
> LoadModule rewrite_module modules/mod_rewrite.so
> LoadModule headers_module modules/mod_headers.so
>
> RewriteEngine On
>
> RequestHeader set Host www.somehost.com
>
> RewriteRule /cd4(.*) http://www.backend1:8080/cd4$1 [P]
>
> result between Apache en backend
> GET /cd4/survey.htm HTTP/1.1\r\n
> Host: www.backend.com:8080\r\n
>
> Is there something that I'm overlooking? (processing order of modules?)

I don't believe Host can be overridden.  It is set just before the request.
Why doesn't ProxyPreserveHost work for you?  The alternative is to
monkey with name resolution on the reverse proxy so that
www.somehost.com maps to the IP of www.backend1 and then use
www.somehost.com in your RewriteRule.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org