Forum Discussion

Jon_46044's avatar
Jon_46044
Icon for Nimbostratus rankNimbostratus
Oct 02, 2007

Simple iRule Help (Header strip and insert)

We're attempting to utilize a current software hack load balance for our company website (I'm well aware a set of LTMs can Loadbalance, but for current management issues, we have to leave the site as it is...)

 

 

Currently, a user logs in and based on the division of the site they're logging into, they get directed to a specific server... such as...

 

 

base site, www.x.com, log in, redirect to www29.x.com.

 

 

We want to strip the www29 from the URL using an irule, but notate the server number in the header/cookie, to keep persistance to that server for the users (session info is cached on a server basis, not site basis).

 

 

This is the error message we're getting currently:

 

 

01070151:3: Rule [Server_Hash] error: line 1: [wrong args] [when HTTP_RESPONSE{] line 4: [command is not valid in the current scope] [regexp.com} [HTTP::host] domain server] line 4: [command is not valid in the current scope] [HTTP::host] line 7: [command is not valid in the current scope] [persist hash $server] line 10: [command is not valid in the current scope] [HTTP::redirect http://www.studyisland.com/[HTTP::uri]] line 10:

 

[command is not valid in the current scope] [HTTP::uri] line 11: [command is not valid in the current scope] [}]

 

 

Our iRule:

 

 

when HTTP_RESPONSE{

 

 

get HTTP information

 

regexp {\.[\w]+)\.com} [HTTP::host] domain server

 

 

set persistance

 

persist hash $server

 

 

redirect client

 

HTTP::redirect "http://www.x.com/[HTTP::uri]"

 

}

 

 

Anyone have a suggestion as to what we're doing wrong here?

 

 

Thanks!

 

  • Patrick_Chang_7's avatar
    Patrick_Chang_7
    Historic F5 Account
    I think you need a space between the HTTP_RESPONSE and the {.

     

    However, this will not work. I think you need both an HTTP_RESPONSE and an HTTP_REQUEST. You cannot redirect a RESPONSE. You need to redirect the REQUEST based upon the RESPONSE.
  • That space did fix the main error, but obviously, we're still confused as to how to write the iRule... thoughts?