Forum Discussion

danjerman_19651's avatar
danjerman_19651
Icon for Nimbostratus rankNimbostratus
Sep 28, 2009

Pool level header insert or cookie persistence via iRule?

Hi,

 

 

I have a v4 config that is rule based..

 

 

i.e. if condition a then use pool pool_a elseif condition b use pool pool_b

 

 

pool pool_a {

 

header insert "ClientIPAddress: ${client_addr}"

 

member x.x.x.x:1234

 

member x.x.y.y:1234

 

}

 

 

pool pool_b {

 

persist_mode cookie

 

cookie_mode insert

 

cookie_name Mycookie

 

cookie_expiration 0d 00:30:00

 

member x.x.x.x:5678

 

member x.x.y.y:5678

 

}

 

 

 

...I now need to migrate this to v9 but am having issues with how to select the cookie persistence or header insert within the rule. The bit for selecting the pool based on HTTP::uri is straightforward but as there doesn't seem to be a way to attach header insert or cookie persistence at the pool level (only at the VIP level) in v9, I'm not sure what to do.

 

 

I'm think the rule is the solution but am not sure. Can anyone point me in the right direction please?

 

 

Many Thanks

 

DM

 

2 Replies

  • Hi DM,

    The following example is v9 iRule of something that may be close what you are looking for:

     
     when HTTP_REQUEST { 
      if {[HTTP::uri] eq "/blah" } {  
          HTTP::header insert "ClientIPAddress" [IP::client_addr] 
          pool poolA 
      } elseif{ [HTTP::uri] eq "/blahblah" } { 
         persist cookie insert "Blah_poolb_Cookie" "0d 00:30:00" 
         pool poolB 
      } 
     } 
      
     

    or via the SWITCH command

     
     when HTTP_REQUEST { 
        switch -glob [HTTP::uri] { 
          "/blah" {  
                   HTTP::header insert "ClientIPAddress" [IP::client_addr] 
                   pool poolA 
                     } 
           "/blahBlah" { 
                   persist cookie insert "Blah_poolb_Cookie" "0d 00:30:00" 
                   pool poolB 
                           } 
           
        } 
     } 
     

    I hope this helps

    CB