Rewriting Redirect 302 headers so that redirection goes through the

Rewriting Redirect 302 headers so that redirection goes through the

am 22.02.2010 16:51:24 von leeand00

I am currently attempting to use my.domain.com as a proxy through which
users of my site access a business partners site:
http://domain.to_proxy_through_my_domain.com/

below is the configuration I have so far:

>#Load Files needed for proxy_html_module
>
>
>#Proxy Support
>LoadModule proxy_module modules/mod_proxy.so
>
>#HTTP Support
>LoadModule proxy_http_module modules/mod_proxy_http.so
>LoadModule headers_module modules/mod_headers.so
>LoadModule deflate_module modules/mod_deflate.so
>#LoadFile "C://www/gra/mod_proxy_html/zlib1.dll"
>#LoadFile "C://www/gra/mod_proxy_html/iconv.dll"
>
># for proxy_html_module
>LoadFile "C://www/gra/mod_proxy_html/libxml2.dll"

># rewrites HMTL URLs for proxied pages
>LoadModule proxy_html_module modules/mod_proxy_html.so

># Turn off forward proxying
>ProxyRequests Off

>
> Order deny,allow
> Allow from all
>


># Forward /my-gateway to http://domain.to_proxy_through_my_domain.com/
>ProxyPass /my-gateway/ http://domain.to_proxy_through_my_domain.com/
>
>
> # ReWrite response headers
> ProxyPassReverse /
> # Enable link rewriting
> SetOutputFilter proxy-html
> # Apparently compression causes problems in mod_proxy_html
> RequestHeader unset Accept-Encoding
>
> ProxyHTMLExtended On
> ProxyHTMLURLMap .* http://my.domain.com/my-gateway/$1 Rihe
>
> ProxyHTMLLinks form action
>



Thus far it works until the point at which the user logs in to my
business partners domain
(http://domain.to_proxy_through_my_domain.com)


I used fiddler to track what happens during the request where the user logs=
in:

1. the browser makes the request to login:

>Request:

>POST /my-gateway/default.asp?do=3Dlogin HTTP/1.1
>Accept: image/gif, image/jpeg, image/pjpeg, application/x-ms-application, =
application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap=
, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/mswo=
rd, application/x-shockwave-flash, */*
>
>Referer: http://my.domain.com/my-gateway/
>Accept-Language: en-us
>User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trid=
ent/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729=
; .NET CLR 3.0.30729)
>Content-Type: application/x-www-form-urlencoded
>Accept-Encoding: gzip, deflate
>Host: my.domain.com
>Content-Length: 47
>Connection: Keep-Alive
>Pragma: no-cache
>Cookie: sessionguid=3D%7B0DC785C5%2DE137%2D4514%2D826E%2D959A9D831E1 9%7D; =
ASPSESSIONIDASQQBQSA=3DNEMKJJBCMHMAENLDDOGKBNDN

>username=3Dtest&password=3Dtestpassword&Submit=3DLog+In


The response that the user gets back redirects them directly to my
business partners website, instead of through the proxy that I've
setup on my domain:

>Response:
>
>HTTP/1.1 302 Object moved
>Date: Mon, 22 Feb 2010 14:02:02 GMT
>Server: Microsoft-IIS/5.0
>Location: http://domain.to_proxy_through_my_domain.com/default.asp?Ses sion=
GUID=3D{02F9DB52-1907-48DF-BE08-E61777D6B192}&do=3Dproducts
>Content-Type: text/html;charset=3Dutf-8
>Cache-control: private
>Set-Cookie: sessionguid=3D%7B02F9DB52%2D1907%2D48DF%2DBE08%2DE61777D6B19 2%=
7D; expires=3DTue, 22-Feb-2011 06:00:00 GMT; path=3D/
>Content-Length: 235
>Keep-Alive: timeout=3D5, max=3D100
>Connection: Keep-Alive

>Object moved

Object Moved

T=
his object may be found ..com/default.asp?SessionGUID=3D{02F9DB52-1907-48DF-BE08-E61 777D6B192}&d=
o=3Dproducts">here
.

How do I rewrite the headers so that the "Location: " header above reads
>"http://my.domain.com/my-gateway/default.asp?SessionGUID=3D {02F9DB52-1907-=
48DF-BE08-E61777D6B192}&do=3Dproducts"
instead of
>"http://domain.to_proxy_through_my_domain.com/default.asp?S essionGUID=3D{0=
2F9DB52-1907-48DF-BE08-E61777D6B192}&do=3Dproducts"

Thank you,
Andrew J. Leer

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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: Rewriting Redirect 302 headers so that redirection

am 22.02.2010 17:27:52 von Tom Evans

On Mon, Feb 22, 2010 at 3:51 PM, Andrew J. Leer wrot=
e:
> I am currently attempting to use my.domain.com as a proxy through which
> users of my site access a business partners site:
> http://domain.to_proxy_through_my_domain.com/
>
> below is the configuration I have so far:
....
> How do I rewrite the headers so that the "Location: " header above reads
>>"http://my.domain.com/my-gateway/default.asp?SessionGUID=3 D{02F9DB52-1907=
-48DF-BE08-E61777D6B192}&do=3Dproducts"
> instead of
>>"http://domain.to_proxy_through_my_domain.com/default.asp? SessionGUID=3D{=
02F9DB52-1907-48DF-BE08-E61777D6B192}&do=3Dproducts"
>
> Thank you,
>   Andrew J. Leer

Use ProxyPassReverse, as described here:

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypas sreverse

Cheers

Tom

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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