Forum Discussion

Michael_107360's avatar
Feb 11, 2014

Overwrite Response Headers with existing pool selection irule

I have an application that direct's traffic to a one of 2 pools and the irule works perfectly

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/ac" { pool V249.48-P31202 } "/client" { pool V249.48-P31203 } } }

 

Now they are having a problem as they are getting a 302 from the server for one URL and they want to overwrite the respone header as follows:

 

Change from Location: http://xyz.abc.com:31202/ac-fedmgr/affwebservices/public/saml2sso?SPID=AITTAC To https://xyz.abc.com/ac-fedmgr/affwebservices/public/saml2sso?SPID=AITTAC

 

I have no idea on how to add this to the existing IRULE if any one is out there please advise.

 

3 Replies

  • If you're just looking to replace the redirect URL, add this to your existing iRule (modify as required):

    when HTTP_RESPONSE {    
        if { [HTTP::header exists Location] } {        
            HTTP::header replace Location [string map {"http://xyz.abc.com:31202" "https://xyz.abc.com"} [HTTP::header Location]]
        }
    }
    

    If the response event sees a Location header, present in a redirect, it will perform a string replacement of the offending URL.

  • the problem is that it is coming in on the save virtual server.....as the irule is applied.

     

    isn't it correct? ssoiextrafedqatmp.ext.ampf.com is resolved to the virtual server ip, isn't it?

     

  • If you're caught in a redirect loop, there's a very good chance that the application is causing this because it doesn't like what the client is asking for. Sometimes this is a specific URI value, but more often than not I find its a Host header. Give this a shot: add the following to the top of your HTTP_REQUEST event.

    HTTP::header replace Host "ssoiextrafedqatmp.ext.ampf.com:31202"    
    

    Otherwise, take a closer look at what it's actually redirecting you to.