Topic: Rewriting redirect 302 headers using Apache2 module? (Page 1 of 1) Pages that link to <a href="" title="Pages that link to Topic: Rewriting redirect 302 headers using Apache2 module? (Page 1 of 1)" rel="nofollow" >Topic: Rewriting redirect 302 headers using Apache2 module? <span class="small">(Page 1 of 1)</span>\

Paranoid (IV) Inmate

From: Johnstown, PA
Insane since: Mar 2002

IP logged posted posted 02-22-2010 17:02 Edit Quote

I am currently attempting to use as a proxy through which
users of my site access a business partners site:

below is the configuration I have so far:

#Load Files needed for proxy_html_module

#Proxy Support
LoadModule  proxy_module         modules/

#HTTP Support
LoadModule  proxy_http_module    modules/
LoadModule  headers_module       modules/
LoadModule  deflate_module       modules/
#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/

# Turn off forward proxying
ProxyRequests Off

<Proxy *>
  Order deny,allow
  Allow from all

# Forward /my-gateway to
ProxyPass /my-gateway/

<Location /my-gateway/>
  # 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 .*$1 Rihe
  ProxyHTMLLinks	form		action

Thus far it works until the point at which the user logs in to my business partners domain (

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

the browser makes the request to login:


POST /my-gateway/default.asp?do=login HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/, application/xaml+xml, application/x-ms-xbap, application/, application/, application/msword, application/x-shockwave-flash, */*

Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/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
Content-Length: 47
Connection: Keep-Alive
Pragma: no-cache


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:


HTTP/1.1 302 Object moved
Date: Mon, 22 Feb 2010 14:02:02 GMT
Server: Microsoft-IIS/5.0
Content-Type: text/html;charset=utf-8
Cache-control: private
Set-Cookie: sessionguid=%7B02F9DB52%2D1907%2D48DF%2DBE08%2DE61777D6B192%7D; expires=Tue, 22-Feb-2011 06:00:00 GMT; path=/
Content-Length: 235
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive

<html><head><title>Object moved</title></head><body><h1>Object Moved</h1>This object may be found <a href="{02F9DB52-1907-48DF-BE08-E61777D6B192}&amp;do=products">here</a>.</body></html>

How do I rewrite the headers so that the "Location: " header above reads


instead of


Thank you,

Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

IP logged posted posted 02-23-2010 18:56 Edit Quote

ProxyPassReverse directive is used to instruct Apache to adjust Location, Content-Location and URI headers in HTTP responses. Looking at your configuration, I think that you've specified this directive in a wrong way.

Example code from Apache documentation looks like this:

ProxyPass /mirror/foo/
ProxyPassReverse /mirror/foo/
ProxyPassReverseCookiePath / /mirror/foo/

Read more about ProxyPass* directives and their usage at:

Also note that Apache will only overwrite addresses in HTTP headers, if returned page contains hard coded links to proxied domain, they will by-pass your proxy, too. In order to rewrite those links you need to use third party module (as mentioned in Apache documentation above).

Post Reply
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
Your Text:
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu