You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Todd Volkert <tv...@gmail.com> on 2009/12/17 18:40:45 UTC

[users@httpd] How to preserve all request headers in reverse proxy (mod_proxy)

Hi all:

In httpd 2.2, is it possible to preserve all HTTP headers when using
mod_proxy to provide a reverse proxy?

Here's my desired setup: I'm running two domains on one server backed by one
Tomcat instance.  I'm trying to run httpd as a reverse proxy to send
http://www.domain1.com/... to http://localhost:8080/domain1/... and
http://www.domain2.com/... to http://localhost:8080/domain2/... (with HTTPS
traffic going to port 8443).    Starting to play with this, I've set up the
following config:

ProxyRequests Off

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass / http://localhost:8080/domain1/
ProxyPassReverse / http://localhost:8080/domain1/

However, the request headers are being lost in the process.  I'd like to
keep them all in tact.  Is there any way to accomplish this?  The
"ProxyPreserveHost" works for the host header, but what about the rest?

Thanks for the help!
-T

Re: [users@httpd] Re: How to preserve all request headers in reverse proxy (mod_proxy)

Posted by Todd Volkert <tv...@gmail.com>.
Haha - the problem is I'm an idiot :)  Your message made me go back and
check my assumptions, and sure enough, I took stupid pills today.

I had created a test page that spits out the request headers in HTML, and I
checked the page in Firefox bypassing the proxy, then checked it *by
telnetting to port 80* using the proxy.  Of course there were no user-agent
request headers when I used telnet!  I saw the lack of request headers and
thought "the proxy is dropping them!"

<sheepish-grin/>,
-T

On Thu, Dec 17, 2009 at 6:01 PM, Nick Kew <ni...@webthing.com> wrote:

> Todd Volkert wrote:
>
>> Actually, I'm not even sure what I'm trying to do is possible - can
>> someone confirm that I'm attempting something that can be done? :)
>>
>> Basically, I have foo.war and bar.war and own the foo.com <http://foo.com>
>> and bar.com <http://bar.com> domains.  I want to deploy the two web-apps
>> in Tomcat on port 8080 and have httpd send http://www.foo.com/ to
>> http://localhost:8080/foo/ and http://www.bar.com/ to
>> http://localhost:8080/bar/ so that each web-app looks like its own
>> top-level web-app in its own domain.  Is this doable, 'cause I can't seem to
>> find anyone out there who's done it :)
>>
>
> What's the problem?
>
> The rules for which request headers are passed through are determined
> by the HTTP standard, not by Apache.  In some cases you have choices,
> documented in the mod_proxy_http page.
>
> If you tell us what's really the problem, maybe someone can help.
>
> --
> Nick Kew
>
> ---------------------------------------------------------------------
> 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] Re: How to preserve all request headers in reverse proxy (mod_proxy)

Posted by Nick Kew <ni...@webthing.com>.
Todd Volkert wrote:
> Actually, I'm not even sure what I'm trying to do is possible - can 
> someone confirm that I'm attempting something that can be done? :)
> 
> Basically, I have foo.war and bar.war and own the foo.com 
> <http://foo.com> and bar.com <http://bar.com> domains.  I want to deploy 
> the two web-apps in Tomcat on port 8080 and have httpd send 
> http://www.foo.com/ to http://localhost:8080/foo/ and 
> http://www.bar.com/ to http://localhost:8080/bar/ so that each web-app 
> looks like its own top-level web-app in its own domain.  Is this doable, 
> 'cause I can't seem to find anyone out there who's done it :)

What's the problem?

The rules for which request headers are passed through are determined
by the HTTP standard, not by Apache.  In some cases you have choices,
documented in the mod_proxy_http page.

If you tell us what's really the problem, maybe someone can help.

-- 
Nick Kew

---------------------------------------------------------------------
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


[users@httpd] Re: How to preserve all request headers in reverse proxy (mod_proxy)

Posted by Todd Volkert <tv...@gmail.com>.
Actually, I'm not even sure what I'm trying to do is possible - can someone
confirm that I'm attempting something that can be done? :)

Basically, I have foo.war and bar.war and own the foo.com and
bar.comdomains.  I want to deploy the two web-apps in Tomcat on port
8080 and have
httpd send http://www.foo.com/ to http://localhost:8080/foo/ and
http://www.bar.com/ to http://localhost:8080/bar/ so that each web-app looks
like its own top-level web-app in its own domain.  Is this doable, 'cause I
can't seem to find anyone out there who's done it :)

-T

On Thu, Dec 17, 2009 at 12:40 PM, Todd Volkert <tv...@gmail.com> wrote:

> Hi all:
>
> In httpd 2.2, is it possible to preserve all HTTP headers when using
> mod_proxy to provide a reverse proxy?
>
> Here's my desired setup: I'm running two domains on one server backed by
> one Tomcat instance.  I'm trying to run httpd as a reverse proxy to send
> http://www.domain1.com/... to http://localhost:8080/domain1/... and
> http://www.domain2.com/... to http://localhost:8080/domain2/... (with
> HTTPS traffic going to port 8443).    Starting to play with this, I've set
> up the following config:
>
> ProxyRequests Off
>
> <Proxy *>
>     Order deny,allow
>     Allow from all
> </Proxy>
>
> ProxyPass / http://localhost:8080/domain1/
> ProxyPassReverse / http://localhost:8080/domain1/
>
> However, the request headers are being lost in the process.  I'd like to
> keep them all in tact.  Is there any way to accomplish this?  The
> "ProxyPreserveHost" works for the host header, but what about the rest?
>
> Thanks for the help!
> -T
>
>