Forum Discussion

Rob_78584's avatar
Rob_78584
Icon for Nimbostratus rankNimbostratus
May 03, 2007

Modify host in HTTP Redirect

I have VS-A going to a pool with Server-A. Server-A sends a redirect to the user which points to an unaccessible host (Server-X).

 

 

I need to be able to capture the HTTP redirect from Server-A and modify the host in the HTTP header to point to a different VS (VS-B) based on a different hostname and port combination (instead of Server-X).

 

 

I believe I can pickup the redirect with "when HTTP:RESPONSE", but I'm stuck on the HTTP:header replace part which I think is then required?

 

 

Thanks! Any help appreciated.
  • Hi,

     

     

    please try this irule below. happy trying.

     

     

    when HTTP_RESPONSE {

     

    if {[HTTP::is_redirect]} {

     

    set find "http://VS-A_ipaddress/"

     

    set replace "http://VS-B_ipaddress:port/"

     

    set location [HTTP::header value Location]

     

    HTTP::header replace Location [string map { "http://VS-A_ipaddress/" "http://VS-B_ipaddress:port/"} $location]

     

    }

     

    }

     

     

    regards,