You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Yang Zhang <ya...@gmail.com> on 2012/11/18 23:48:35 UTC

[users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

I have: nginx (port 80) reverse-proxying to apache2 (port 88)
reverse-proxying to a web app (port 5001).

However, when the web app responds with a redirect like `Location:
/foo`, apache2 rewrites this into `Location:
http://host.com:88/sub/foo`, even though port 88 is publicly
inaccessible. I'd like it to just redirect to the relative URL
`Location: /sub/foo`.

Any ideas?

My apache config (using mod_proxy_http, mod_proxy_html, mod_substitute):

      <Location /notes/>
        Allow from all
        ProxyPass http://127.0.0.1:5001/
        SetOutputFilter  proxy-html
        ProxyPassReverse /
        ProxyHTMLURLMap  /   /notes/
        RequestHeader unset Accept-Encoding
        AddOutputFilterByType SUBSTITUTE application/atom+xml
        Substitute "s|127.0.0.1:5001|host.com/notes|"
      </Location>

Thanks.

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Yang Zhang <ya...@gmail.com>.
On Sun, Nov 18, 2012 at 4:03 PM, Nick Kew <ni...@webthing.com> wrote:
> On Sun, 18 Nov 2012 14:48:35 -0800
> Yang Zhang <ya...@gmail.com> wrote:
>
>> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
>> reverse-proxying to a web app (port 5001).
>>
>> However, when the web app responds with a redirect like `Location:
>> /foo`,
>
> That is not valid HTTP.  A Location header must be an absolute URI.

OK, in that case I'd like `Location: http://host.com/sub/foo` and not
`http://host.com:88/sub/foo`.

>
>  apache2 rewrites this into `Location:
>> http://host.com:88/sub/foo`, even though port 88 is publicly
>> inaccessible.
>
> So where does :88 come from?  Looks like a misconfiguration
> somewhere outside the section you quoted.

Well, I know from inspecting the wire traffic that this is coming from
apache's response to nginx (since, again, apache listens on 88).

The top of the config is what specifies this:

<VirtualHost *:88>

>
>
> --
> Nick Kew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>



--
Yang Zhang
http://yz.mit.edu/

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Yang Zhang <ya...@gmail.com>.
`fgrep -ir usecanonicalname /etc/apache2/` turns up nothing.  (FWIW
I'm using the apache2 from Ubuntu 12.04)

On Sun, Nov 18, 2012 at 5:04 PM, Igor Cicimov <ic...@gmail.com> wrote:
>
>
>
> On Mon, Nov 19, 2012 at 11:03 AM, Nick Kew <ni...@webthing.com> wrote:
>>
>> On Sun, 18 Nov 2012 14:48:35 -0800
>> Yang Zhang <ya...@gmail.com> wrote:
>>
>> > I have: nginx (port 80) reverse-proxying to apache2 (port 88)
>> > reverse-proxying to a web app (port 5001).
>> >
>> > However, when the web app responds with a redirect like `Location:
>> > /foo`,
>>
>> That is not valid HTTP.  A Location header must be an absolute URI.
>>
>>  apache2 rewrites this into `Location:
>> > http://host.com:88/sub/foo`, even though port 88 is publicly
>> > inaccessible.
>>
>> So where does :88 come from?  Looks like a misconfiguration
>> somewhere outside the section you quoted.
>
>
> Maybe from UseCanonicalName ??
>>
>>
>>
>> --
>> Nick Kew
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>



-- 
Yang Zhang
http://yz.mit.edu/

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Igor Cicimov <ic...@gmail.com>.
On Mon, Nov 19, 2012 at 11:03 AM, Nick Kew <ni...@webthing.com> wrote:

> On Sun, 18 Nov 2012 14:48:35 -0800
> Yang Zhang <ya...@gmail.com> wrote:
>
> > I have: nginx (port 80) reverse-proxying to apache2 (port 88)
> > reverse-proxying to a web app (port 5001).
> >
> > However, when the web app responds with a redirect like `Location:
> > /foo`,
>
> That is not valid HTTP.  A Location header must be an absolute URI.
>
>  apache2 rewrites this into `Location:
> > http://host.com:88/sub/foo`, even though port 88 is publicly
> > inaccessible.
>
> So where does :88 come from?  Looks like a misconfiguration
> somewhere outside the section you quoted.
>

Maybe from UseCanonicalName ??

>
>
> --
> Nick Kew
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Nick Kew <ni...@webthing.com>.
On Sun, 18 Nov 2012 14:48:35 -0800
Yang Zhang <ya...@gmail.com> wrote:

> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
> reverse-proxying to a web app (port 5001).
> 
> However, when the web app responds with a redirect like `Location:
> /foo`,

That is not valid HTTP.  A Location header must be an absolute URI.

 apache2 rewrites this into `Location:
> http://host.com:88/sub/foo`, even though port 88 is publicly
> inaccessible.

So where does :88 come from?  Looks like a misconfiguration
somewhere outside the section you quoted.


-- 
Nick Kew

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by "Sharl.Jimh.Tsin" <am...@gmail.com>.
read more @ http://httpd.apache.org/docs/trunk/mod/mod_proxy.html#proxypassreverse

Best regards,
Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**)

Using Gmail? Please read this important notice:
http://www.fsf.org/campaigns/jstrap/gmail?10073.


2012/11/19 Yang Zhang <ya...@gmail.com>:
> (The app server is this: http://gitit.net/README#proxying-to-httpmysite.comwiki)
>
> On Sun, Nov 18, 2012 at 5:55 PM, Yang Zhang <ya...@gmail.com> wrote:
>> This is not an option because the point of my using the proxy in this
>> case is that I need to rewrite the URLs and content (with
>> mod_proxy_html). The app server hosts at / and I need to translate it
>> to a subdirectory /sub.
>>
>> On Sun, Nov 18, 2012 at 5:53 PM, Igor Cicimov <ic...@gmail.com> wrote:
>>>
>>>
>>>
>>> On Mon, Nov 19, 2012 at 12:38 PM, Yang Zhang <ya...@gmail.com> wrote:
>>>>
>>>> On Sun, Nov 18, 2012 at 3:21 PM, Igor Cicimov <ic...@gmail.com> wrote:
>>>> >
>>>> > On Mon, Nov 19, 2012 at 9:48 AM, Yang Zhang <ya...@gmail.com>
>>>> > wrote:
>>>> >>
>>>> >> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
>>>> >> reverse-proxying to a web app (port 5001).
>>>> >>
>>>> >> However, when the web app responds with a redirect like `Location:
>>>> >> /foo`, apache2 rewrites this into `Location:
>>>> >> http://host.com:88/sub/foo`,
>>>> >
>>>> >
>>>> > Yes that's what reverse proxy is all about, it rewrites the Location
>>>> > header
>>>> > using ProxyPassReverseso it doesn't get bypassed in case of backend
>>>> > server
>>>> > redirection.
>>>>
>>>> nginx doesn't do the same rewrite from host.com:88 to host.com - I'd
>>>> also be fine with a solution where nginx does this rewrite as well.
>>>>
>>>> >
>>>> >> even though port 88 is publicly
>>>> >> inaccessible. I'd like it to just redirect to the relative URL
>>>> >> `Location: /sub/foo`.
>>>> >
>>>> >
>>>> > So use a redirect then. Looks like reverse proxy is not applicable for
>>>> > your
>>>> > user case.
>>>>
>>>> What specifically do you mean when you suggest to "use a redirect"?
>>>> Are you suggesting redirecting host.com:88 to host.com?  That's not
>>>> possible because port 88 is not (and should not be) publicly
>>>> reachable.
>>>
>>>
>>> I meant redirecting  /notes/ to the backend using [P] flag if you like
>>> instead of proxying it.
>>>
>>>>
>>>> >
>>>> >>
>>>> >>
>>>> >> Any ideas?
>>>> >>
>>>> >> My apache config (using mod_proxy_http, mod_proxy_html,
>>>> >> mod_substitute):
>>>> >>
>>>> >>       <Location /notes/>
>>>> >>         Allow from all
>>>> >>         ProxyPass http://127.0.0.1:5001/
>>>> >>         SetOutputFilter  proxy-html
>>>> >>         ProxyPassReverse /
>>>> >>         ProxyHTMLURLMap  /   /notes/
>>>> >>         RequestHeader unset Accept-Encoding
>>>> >>         AddOutputFilterByType SUBSTITUTE application/atom+xml
>>>> >>         Substitute "s|127.0.0.1:5001|host.com/notes|"
>>>> >>       </Location>
>>>> >>
>>>> >> Thanks.
>>>> >>
>>>> >> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> >> For additional commands, e-mail: users-help@httpd.apache.org
>>>> >>
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Yang Zhang
>>>> http://yz.mit.edu/
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>>>
>>
>>
>>
>> --
>> Yang Zhang
>> http://yz.mit.edu/
>
>
>
> --
> Yang Zhang
> http://yz.mit.edu/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Yang Zhang <ya...@gmail.com>.
For posterity, Igor's solution is what worked for me - thanks!

Specifically:

      proxy_redirect http://host.com:88/ http://host.com/;

On Sun, Nov 18, 2012 at 9:21 PM, Igor Cicimov <ic...@gmail.com> wrote:
>
>
>
> On Mon, Nov 19, 2012 at 12:56 PM, Yang Zhang <ya...@gmail.com> wrote:
>>
>> (The app server is this:
>> http://gitit.net/README#proxying-to-httpmysite.comwiki)
>>
>> On Sun, Nov 18, 2012 at 5:55 PM, Yang Zhang <ya...@gmail.com>
>> wrote:
>> > This is not an option because the point of my using the proxy in this
>> > case is that I need to rewrite the URLs and content (with
>> > mod_proxy_html). The app server hosts at / and I need to translate it
>> > to a subdirectory /sub.
>> >
>> > On Sun, Nov 18, 2012 at 5:53 PM, Igor Cicimov <ic...@gmail.com>
>> > wrote:
>> >>
>> >>
>> >>
>> >> On Mon, Nov 19, 2012 at 12:38 PM, Yang Zhang <ya...@gmail.com>
>> >> wrote:
>> >>>
>> >>> On Sun, Nov 18, 2012 at 3:21 PM, Igor Cicimov <ic...@gmail.com>
>> >>> wrote:
>> >>> >
>> >>> > On Mon, Nov 19, 2012 at 9:48 AM, Yang Zhang <ya...@gmail.com>
>> >>> > wrote:
>> >>> >>
>> >>> >> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
>> >>> >> reverse-proxying to a web app (port 5001).
>> >>> >>
>> >>> >> However, when the web app responds with a redirect like `Location:
>> >>> >> /foo`, apache2 rewrites this into `Location:
>> >>> >> http://host.com:88/sub/foo`,
>> >>> >
>> >>> >
>> >>> > Yes that's what reverse proxy is all about, it rewrites the Location
>> >>> > header
>> >>> > using ProxyPassReverseso it doesn't get bypassed in case of backend
>> >>> > server
>> >>> > redirection.
>> >>>
>> >>> nginx doesn't do the same rewrite from host.com:88 to host.com - I'd
>> >>> also be fine with a solution where nginx does this rewrite as well.
>> >>>
>> >>> >
>> >>> >> even though port 88 is publicly
>> >>> >> inaccessible. I'd like it to just redirect to the relative URL
>> >>> >> `Location: /sub/foo`.
>> >>> >
>> >>> >
>> >>> > So use a redirect then. Looks like reverse proxy is not applicable
>> >>> > for
>> >>> > your
>> >>> > user case.
>> >>>
>> >>> What specifically do you mean when you suggest to "use a redirect"?
>> >>> Are you suggesting redirecting host.com:88 to host.com?  That's not
>> >>> possible because port 88 is not (and should not be) publicly
>> >>> reachable.
>> >>
>> >>
>> >> I meant redirecting  /notes/ to the backend using [P] flag if you like
>> >> instead of proxying it.
>> >>
>> >>>
>> >>> >
>> >>> >>
>> >>> >>
>> >>> >> Any ideas?
>> >>> >>
>> >>> >> My apache config (using mod_proxy_http, mod_proxy_html,
>> >>> >> mod_substitute):
>> >>> >>
>> >>> >>       <Location /notes/>
>> >>> >>         Allow from all
>> >>> >>         ProxyPass http://127.0.0.1:5001/
>> >>> >>         SetOutputFilter  proxy-html
>> >>> >>         ProxyPassReverse /
>> >>> >>         ProxyHTMLURLMap  /   /notes/
>> >>> >>         RequestHeader unset Accept-Encoding
>> >>> >>         AddOutputFilterByType SUBSTITUTE application/atom+xml
>> >>> >>         Substitute "s|127.0.0.1:5001|host.com/notes|"
>> >>> >>       </Location>
>> >>> >>
>> >>> >> Thanks.
>> >>> >>
>> >>> >>
>> >>> >> ---------------------------------------------------------------------
>> >>> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> >>> >> For additional commands, e-mail: users-help@httpd.apache.org
>> >>> >>
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Yang Zhang
>> >>> http://yz.mit.edu/
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> >>> For additional commands, e-mail: users-help@httpd.apache.org
>> >>>
>> >>
>> >
>> >
>> >
>> > --
>> > Yang Zhang
>> > http://yz.mit.edu/
>>
>>
>>
>> --
>> Yang Zhang
>> http://yz.mit.edu/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
> Can't you solve this in nginx? Rewrite the Location header set by apache
> using proxy_redirect?
>



--
Yang Zhang
http://yz.mit.edu/

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Igor Cicimov <ic...@gmail.com>.
On Mon, Nov 19, 2012 at 12:56 PM, Yang Zhang <ya...@gmail.com> wrote:

> (The app server is this:
> http://gitit.net/README#proxying-to-httpmysite.comwiki)
>
> On Sun, Nov 18, 2012 at 5:55 PM, Yang Zhang <ya...@gmail.com>
> wrote:
> > This is not an option because the point of my using the proxy in this
> > case is that I need to rewrite the URLs and content (with
> > mod_proxy_html). The app server hosts at / and I need to translate it
> > to a subdirectory /sub.
> >
> > On Sun, Nov 18, 2012 at 5:53 PM, Igor Cicimov <ic...@gmail.com>
> wrote:
> >>
> >>
> >>
> >> On Mon, Nov 19, 2012 at 12:38 PM, Yang Zhang <ya...@gmail.com>
> wrote:
> >>>
> >>> On Sun, Nov 18, 2012 at 3:21 PM, Igor Cicimov <ic...@gmail.com>
> wrote:
> >>> >
> >>> > On Mon, Nov 19, 2012 at 9:48 AM, Yang Zhang <ya...@gmail.com>
> >>> > wrote:
> >>> >>
> >>> >> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
> >>> >> reverse-proxying to a web app (port 5001).
> >>> >>
> >>> >> However, when the web app responds with a redirect like `Location:
> >>> >> /foo`, apache2 rewrites this into `Location:
> >>> >> http://host.com:88/sub/foo`,
> >>> >
> >>> >
> >>> > Yes that's what reverse proxy is all about, it rewrites the Location
> >>> > header
> >>> > using ProxyPassReverseso it doesn't get bypassed in case of backend
> >>> > server
> >>> > redirection.
> >>>
> >>> nginx doesn't do the same rewrite from host.com:88 to host.com - I'd
> >>> also be fine with a solution where nginx does this rewrite as well.
> >>>
> >>> >
> >>> >> even though port 88 is publicly
> >>> >> inaccessible. I'd like it to just redirect to the relative URL
> >>> >> `Location: /sub/foo`.
> >>> >
> >>> >
> >>> > So use a redirect then. Looks like reverse proxy is not applicable
> for
> >>> > your
> >>> > user case.
> >>>
> >>> What specifically do you mean when you suggest to "use a redirect"?
> >>> Are you suggesting redirecting host.com:88 to host.com?  That's not
> >>> possible because port 88 is not (and should not be) publicly
> >>> reachable.
> >>
> >>
> >> I meant redirecting  /notes/ to the backend using [P] flag if you like
> >> instead of proxying it.
> >>
> >>>
> >>> >
> >>> >>
> >>> >>
> >>> >> Any ideas?
> >>> >>
> >>> >> My apache config (using mod_proxy_http, mod_proxy_html,
> >>> >> mod_substitute):
> >>> >>
> >>> >>       <Location /notes/>
> >>> >>         Allow from all
> >>> >>         ProxyPass http://127.0.0.1:5001/
> >>> >>         SetOutputFilter  proxy-html
> >>> >>         ProxyPassReverse /
> >>> >>         ProxyHTMLURLMap  /   /notes/
> >>> >>         RequestHeader unset Accept-Encoding
> >>> >>         AddOutputFilterByType SUBSTITUTE application/atom+xml
> >>> >>         Substitute "s|127.0.0.1:5001|host.com/notes|"
> >>> >>       </Location>
> >>> >>
> >>> >> Thanks.
> >>> >>
> >>> >>
> ---------------------------------------------------------------------
> >>> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>> >> For additional commands, e-mail: users-help@httpd.apache.org
> >>> >>
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Yang Zhang
> >>> http://yz.mit.edu/
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >>> For additional commands, e-mail: users-help@httpd.apache.org
> >>>
> >>
> >
> >
> >
> > --
> > Yang Zhang
> > http://yz.mit.edu/
>
>
>
> --
> Yang Zhang
> http://yz.mit.edu/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Can't you solve this in nginx? Rewrite the Location header set by apache
using proxy_redirect?

Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Yang Zhang <ya...@gmail.com>.
(The app server is this: http://gitit.net/README#proxying-to-httpmysite.comwiki)

On Sun, Nov 18, 2012 at 5:55 PM, Yang Zhang <ya...@gmail.com> wrote:
> This is not an option because the point of my using the proxy in this
> case is that I need to rewrite the URLs and content (with
> mod_proxy_html). The app server hosts at / and I need to translate it
> to a subdirectory /sub.
>
> On Sun, Nov 18, 2012 at 5:53 PM, Igor Cicimov <ic...@gmail.com> wrote:
>>
>>
>>
>> On Mon, Nov 19, 2012 at 12:38 PM, Yang Zhang <ya...@gmail.com> wrote:
>>>
>>> On Sun, Nov 18, 2012 at 3:21 PM, Igor Cicimov <ic...@gmail.com> wrote:
>>> >
>>> > On Mon, Nov 19, 2012 at 9:48 AM, Yang Zhang <ya...@gmail.com>
>>> > wrote:
>>> >>
>>> >> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
>>> >> reverse-proxying to a web app (port 5001).
>>> >>
>>> >> However, when the web app responds with a redirect like `Location:
>>> >> /foo`, apache2 rewrites this into `Location:
>>> >> http://host.com:88/sub/foo`,
>>> >
>>> >
>>> > Yes that's what reverse proxy is all about, it rewrites the Location
>>> > header
>>> > using ProxyPassReverseso it doesn't get bypassed in case of backend
>>> > server
>>> > redirection.
>>>
>>> nginx doesn't do the same rewrite from host.com:88 to host.com - I'd
>>> also be fine with a solution where nginx does this rewrite as well.
>>>
>>> >
>>> >> even though port 88 is publicly
>>> >> inaccessible. I'd like it to just redirect to the relative URL
>>> >> `Location: /sub/foo`.
>>> >
>>> >
>>> > So use a redirect then. Looks like reverse proxy is not applicable for
>>> > your
>>> > user case.
>>>
>>> What specifically do you mean when you suggest to "use a redirect"?
>>> Are you suggesting redirecting host.com:88 to host.com?  That's not
>>> possible because port 88 is not (and should not be) publicly
>>> reachable.
>>
>>
>> I meant redirecting  /notes/ to the backend using [P] flag if you like
>> instead of proxying it.
>>
>>>
>>> >
>>> >>
>>> >>
>>> >> Any ideas?
>>> >>
>>> >> My apache config (using mod_proxy_http, mod_proxy_html,
>>> >> mod_substitute):
>>> >>
>>> >>       <Location /notes/>
>>> >>         Allow from all
>>> >>         ProxyPass http://127.0.0.1:5001/
>>> >>         SetOutputFilter  proxy-html
>>> >>         ProxyPassReverse /
>>> >>         ProxyHTMLURLMap  /   /notes/
>>> >>         RequestHeader unset Accept-Encoding
>>> >>         AddOutputFilterByType SUBSTITUTE application/atom+xml
>>> >>         Substitute "s|127.0.0.1:5001|host.com/notes|"
>>> >>       </Location>
>>> >>
>>> >> Thanks.
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>> >> For additional commands, e-mail: users-help@httpd.apache.org
>>> >>
>>> >
>>>
>>>
>>>
>>> --
>>> Yang Zhang
>>> http://yz.mit.edu/
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>
>>
>
>
>
> --
> Yang Zhang
> http://yz.mit.edu/



-- 
Yang Zhang
http://yz.mit.edu/

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Yang Zhang <ya...@gmail.com>.
This is not an option because the point of my using the proxy in this
case is that I need to rewrite the URLs and content (with
mod_proxy_html). The app server hosts at / and I need to translate it
to a subdirectory /sub.

On Sun, Nov 18, 2012 at 5:53 PM, Igor Cicimov <ic...@gmail.com> wrote:
>
>
>
> On Mon, Nov 19, 2012 at 12:38 PM, Yang Zhang <ya...@gmail.com> wrote:
>>
>> On Sun, Nov 18, 2012 at 3:21 PM, Igor Cicimov <ic...@gmail.com> wrote:
>> >
>> > On Mon, Nov 19, 2012 at 9:48 AM, Yang Zhang <ya...@gmail.com>
>> > wrote:
>> >>
>> >> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
>> >> reverse-proxying to a web app (port 5001).
>> >>
>> >> However, when the web app responds with a redirect like `Location:
>> >> /foo`, apache2 rewrites this into `Location:
>> >> http://host.com:88/sub/foo`,
>> >
>> >
>> > Yes that's what reverse proxy is all about, it rewrites the Location
>> > header
>> > using ProxyPassReverseso it doesn't get bypassed in case of backend
>> > server
>> > redirection.
>>
>> nginx doesn't do the same rewrite from host.com:88 to host.com - I'd
>> also be fine with a solution where nginx does this rewrite as well.
>>
>> >
>> >> even though port 88 is publicly
>> >> inaccessible. I'd like it to just redirect to the relative URL
>> >> `Location: /sub/foo`.
>> >
>> >
>> > So use a redirect then. Looks like reverse proxy is not applicable for
>> > your
>> > user case.
>>
>> What specifically do you mean when you suggest to "use a redirect"?
>> Are you suggesting redirecting host.com:88 to host.com?  That's not
>> possible because port 88 is not (and should not be) publicly
>> reachable.
>
>
> I meant redirecting  /notes/ to the backend using [P] flag if you like
> instead of proxying it.
>
>>
>> >
>> >>
>> >>
>> >> Any ideas?
>> >>
>> >> My apache config (using mod_proxy_http, mod_proxy_html,
>> >> mod_substitute):
>> >>
>> >>       <Location /notes/>
>> >>         Allow from all
>> >>         ProxyPass http://127.0.0.1:5001/
>> >>         SetOutputFilter  proxy-html
>> >>         ProxyPassReverse /
>> >>         ProxyHTMLURLMap  /   /notes/
>> >>         RequestHeader unset Accept-Encoding
>> >>         AddOutputFilterByType SUBSTITUTE application/atom+xml
>> >>         Substitute "s|127.0.0.1:5001|host.com/notes|"
>> >>       </Location>
>> >>
>> >> Thanks.
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> >> For additional commands, e-mail: users-help@httpd.apache.org
>> >>
>> >
>>
>>
>>
>> --
>> Yang Zhang
>> http://yz.mit.edu/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>



-- 
Yang Zhang
http://yz.mit.edu/

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Igor Cicimov <ic...@gmail.com>.
On Mon, Nov 19, 2012 at 12:38 PM, Yang Zhang <ya...@gmail.com> wrote:

> On Sun, Nov 18, 2012 at 3:21 PM, Igor Cicimov <ic...@gmail.com> wrote:
> >
> > On Mon, Nov 19, 2012 at 9:48 AM, Yang Zhang <ya...@gmail.com>
> wrote:
> >>
> >> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
> >> reverse-proxying to a web app (port 5001).
> >>
> >> However, when the web app responds with a redirect like `Location:
> >> /foo`, apache2 rewrites this into `Location:
> >> http://host.com:88/sub/foo`,
> >
> >
> > Yes that's what reverse proxy is all about, it rewrites the Location
> header
> > using ProxyPassReverseso it doesn't get bypassed in case of backend
> server
> > redirection.
>
> nginx doesn't do the same rewrite from host.com:88 to host.com - I'd
> also be fine with a solution where nginx does this rewrite as well.
>
> >
> >> even though port 88 is publicly
> >> inaccessible. I'd like it to just redirect to the relative URL
> >> `Location: /sub/foo`.
> >
> >
> > So use a redirect then. Looks like reverse proxy is not applicable for
> your
> > user case.
>
> What specifically do you mean when you suggest to "use a redirect"?
> Are you suggesting redirecting host.com:88 to host.com?  That's not
> possible because port 88 is not (and should not be) publicly
> reachable.
>

I meant redirecting  /notes/ to the backend using [P] flag if you like
instead of proxying it.


> >
> >>
> >>
> >> Any ideas?
> >>
> >> My apache config (using mod_proxy_http, mod_proxy_html, mod_substitute):
> >>
> >>       <Location /notes/>
> >>         Allow from all
> >>         ProxyPass http://127.0.0.1:5001/
> >>         SetOutputFilter  proxy-html
> >>         ProxyPassReverse /
> >>         ProxyHTMLURLMap  /   /notes/
> >>         RequestHeader unset Accept-Encoding
> >>         AddOutputFilterByType SUBSTITUTE application/atom+xml
> >>         Substitute "s|127.0.0.1:5001|host.com/notes|"
> >>       </Location>
> >>
> >> Thanks.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >> For additional commands, e-mail: users-help@httpd.apache.org
> >>
> >
>
>
>
> --
> Yang Zhang
> http://yz.mit.edu/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Yang Zhang <ya...@gmail.com>.
On Sun, Nov 18, 2012 at 3:21 PM, Igor Cicimov <ic...@gmail.com> wrote:
>
> On Mon, Nov 19, 2012 at 9:48 AM, Yang Zhang <ya...@gmail.com> wrote:
>>
>> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
>> reverse-proxying to a web app (port 5001).
>>
>> However, when the web app responds with a redirect like `Location:
>> /foo`, apache2 rewrites this into `Location:
>> http://host.com:88/sub/foo`,
>
>
> Yes that's what reverse proxy is all about, it rewrites the Location header
> using ProxyPassReverseso it doesn't get bypassed in case of backend server
> redirection.

nginx doesn't do the same rewrite from host.com:88 to host.com - I'd
also be fine with a solution where nginx does this rewrite as well.

>
>> even though port 88 is publicly
>> inaccessible. I'd like it to just redirect to the relative URL
>> `Location: /sub/foo`.
>
>
> So use a redirect then. Looks like reverse proxy is not applicable for your
> user case.

What specifically do you mean when you suggest to "use a redirect"?
Are you suggesting redirecting host.com:88 to host.com?  That's not
possible because port 88 is not (and should not be) publicly
reachable.

>
>>
>>
>> Any ideas?
>>
>> My apache config (using mod_proxy_http, mod_proxy_html, mod_substitute):
>>
>>       <Location /notes/>
>>         Allow from all
>>         ProxyPass http://127.0.0.1:5001/
>>         SetOutputFilter  proxy-html
>>         ProxyPassReverse /
>>         ProxyHTMLURLMap  /   /notes/
>>         RequestHeader unset Accept-Encoding
>>         AddOutputFilterByType SUBSTITUTE application/atom+xml
>>         Substitute "s|127.0.0.1:5001|host.com/notes|"
>>       </Location>
>>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>



--
Yang Zhang
http://yz.mit.edu/

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


Re: [users@httpd] How to prevent mod_proxy from rewriting redirects into absolute URLs?

Posted by Igor Cicimov <ic...@gmail.com>.
On Mon, Nov 19, 2012 at 9:48 AM, Yang Zhang <ya...@gmail.com> wrote:

> I have: nginx (port 80) reverse-proxying to apache2 (port 88)
> reverse-proxying to a web app (port 5001).
>
> However, when the web app responds with a redirect like `Location:
> /foo`, apache2 rewrites this into `Location:
> http://host.com:88/sub/foo`,


Yes that's what reverse proxy is all about, it rewrites the Location header
using ProxyPassReverseso it doesn't get bypassed in case of backend server
redirection.

even though port 88 is publicly
> inaccessible. I'd like it to just redirect to the relative URL
> `Location: /sub/foo`.
>

So use a redirect then. Looks like reverse proxy is not applicable for your
user case.


>
> Any ideas?
>
> My apache config (using mod_proxy_http, mod_proxy_html, mod_substitute):
>
>       <Location /notes/>
>         Allow from all
>         ProxyPass http://127.0.0.1:5001/
>         SetOutputFilter  proxy-html
>         ProxyPassReverse /
>         ProxyHTMLURLMap  /   /notes/
>         RequestHeader unset Accept-Encoding
>         AddOutputFilterByType SUBSTITUTE application/atom+xml
>         Substitute "s|127.0.0.1:5001|host.com/notes|"
>       </Location>
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>