You are viewing a plain text version of this content. The canonical link for it is here.
Posted to portalapps-user@portals.apache.org by Jeroen van Dun <Jv...@rocketsoftware.com> on 2013/07/01 10:58:21 UTC

RE: ReverseProxy and "HTTP/1.1 302 Moved Temporarily" handling

Hi Woonsan,

Thank you for your reply! :) I think your analysis is right but my location header does contain locahost:8080. Please find a trace of the communication between my browser and Tomcat below:


Request:
GET apa-webcontent-war-1.3/rproxy/test/shop/item?number=5 HTTP/1.1

Host: localhost:8080

Connection: keep-alive

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36

Referer: http://localhost:8080/apa-webcontent-war-1.3/rproxy/test/items/seagate/18457?&ChosenOfferId=0

Accept-Encoding: gzip,deflate,sdch

Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4


Response:
HTTP/1.1 302 Moved Temporarily

Server: Apache-Coyote/1.1

Location: http://localhost:8080/webshop/details?number=5

Content-Length: 0

Date: Mon, 01 Jul 2013 08:00:46 GMT



So it looks like the location header does give an absolute URI but the wrong one? I would expect the URI to contain "apa-webcontent-war-1.3/rproxy/test" as well?

Best,

Jeroen

From: Woonsan Ko [mailto:woon_san@yahoo.com]
Sent: Saturday, June 29, 2013 9:03 PM
To: portalapps-user@portals.apache.org
Subject: Re: ReverseProxy and "HTTP/1.1 302 Moved Temporarily" handling

Hi Jeroen,

The ReverseProxyService implementation (RewritableHttpReverseProxyServiceImpl.java) rewrites the "Location" header value on 302 response.
So, it should be able to rewrite the returned "Location" header value to a proper proxied path instead. (See #475~ in RewritableHttpReverseProxyServiceImpl.java if you want to debug.)
The local proxy path resolution from the Location header value will translate the *absolute URI* given by Location header value to local proxied URI, based on the proxy path configuration.
One possible cause might be the returned Location header from the webshop application doesn't give an *absolute URI*. The current code doesn't seem to resolve remote URL if the Location header value is a relative URI.
This can be improved simply because it should be aware of the called remote base URI and it should have prepended it in that case.
Could you check if the returned Location header value doesn't start with http(s)://localhost:8080 ?

Regards,

Woonsan


________________________________
From: Jeroen van Dun <Jv...@rocketsoftware.com>>
To: "portalapps-user@portals.apache.org<ma...@portals.apache.org>" <po...@portals.apache.org>>
Sent: Friday, June 28, 2013 11:07 AM
Subject: ReverseProxy and "HTTP/1.1 302 Moved Temporarily" handling

Hi,

Is there anything I should configure to have the ReverseProxy handle HTTP moved responses?

This url: http://localhost:8080/apa-webcontent-war-1.3/rproxy/test/shop/item?number=5 (context rproxy, path test) generates:

GET /shop/item?number=5

The server responds with:
HTTP/1.1 302 Moved Temporarily
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Length: 390
Via: 1.1 DOR-S-TMG01
Date: Fri, 28 Jun 2013 11:48:48 GMT
Location: /webshop/details?number=5

The browser then tries to open : http://localhost:8080/webshop/details?number=5 instead of http://localhost:8080/apa-webcontent-war-1.3/rproxy/test/webshop/details?number=5

How can I fix this?

Thanks,

Jeroen