You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Gary Gregory <ga...@gmail.com> on 2017/05/11 07:02:00 UTC

Rewriting the path of a URI in org.apache.http.examples.nio.NHttpReverseProxy

Hi All,

(I am not proposing to change NHttpReverseProxy but my code in a descendant
of NHttpReverseProxy).

How would I change the path of a request's URI before it is forwarded to
the origin server?

Thank you,
Gary

-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Rewriting the path of a URI in org.apache.http.examples.nio.NHttpReverseProxy

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2017-05-11 at 00:33 -0700, Gary Gregory wrote:
> On May 11, 2017 12:29 AM, "Oleg Kalnichevski" <ol...@apache.org>
> wrote:
> 
> On Thu, 2017-05-11 at 00:02 -0700, Gary Gregory wrote:
> > Hi All,
> > 
> > (I am not proposing to change NHttpReverseProxy but my code in a
> > descendant
> > of NHttpReverseProxy).
> > 
> > How would I change the path of a request's URI before it is
> > forwarded
> > to
> > the origin server?
> > 
> 
> This entirely depends on what kind requests the origin server
> expects.
> If your proxy expects absolute request URIs but the origin does
> relative ones then rewrite the request URI as relative and generate
> Host header with the authority components of the original URI.
> 
> 
> Let's the proxy receives /foo/bar and the origin server wants
> /beep/bop/foo/bar
> 
> Does your suggestion apply?
> 

It does, if the reverse proxy is meant to re-route requests.

Oleg 


> Gary
> 
> 
> Oleg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: Rewriting the path of a URI in org.apache.http.examples.nio.NHttpReverseProxy

Posted by Gary Gregory <ga...@gmail.com>.
On May 11, 2017 12:29 AM, "Oleg Kalnichevski" <ol...@apache.org> wrote:

On Thu, 2017-05-11 at 00:02 -0700, Gary Gregory wrote:
> Hi All,
>
> (I am not proposing to change NHttpReverseProxy but my code in a
> descendant
> of NHttpReverseProxy).
>
> How would I change the path of a request's URI before it is forwarded
> to
> the origin server?
>

This entirely depends on what kind requests the origin server expects.
If your proxy expects absolute request URIs but the origin does
relative ones then rewrite the request URI as relative and generate
Host header with the authority components of the original URI.


Let's the proxy receives /foo/bar and the origin server wants
/beep/bop/foo/bar

Does your suggestion apply?

Gary


Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

Re: Rewriting the path of a URI in org.apache.http.examples.nio.NHttpReverseProxy

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2017-05-11 at 00:02 -0700, Gary Gregory wrote:
> Hi All,
> 
> (I am not proposing to change NHttpReverseProxy but my code in a
> descendant
> of NHttpReverseProxy).
> 
> How would I change the path of a request's URI before it is forwarded
> to
> the origin server?
> 

This entirely depends on what kind requests the origin server expects.
If your proxy expects absolute request URIs but the origin does
relative ones then rewrite the request URI as relative and generate
Host header with the authority components of the original URI.

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org