For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Jonathan_Mansfi's avatar
Jonathan_Mansfi
Icon for Nimbostratus rankNimbostratus
Jun 06, 2016

iRule to allow developers to test specific pool members

I'm new to iRule development, so I apologize if I'm asking a silly question. My department manages the F5 infrastructure, but the resource nodes are managed by multiple internal customers. I have customers who would like to be able to test individual nodes on specific VSs that do not have persistence enabled. I've seen a few posts which seem to mention ways to do this, but I haven't been able to get it to work yet. I've tried variations of the following code without success:

 

when HTTP_REQUEST {
    Check the requested URI
   switch -glob [string tolower [HTTP::path]] {
      "/persist1*" {
          Direct traffic to pool member 1
        persist source_addr 
    session add source_addr [IP::client_addr] 10.75.65.55 3600
      }
      "/persist2*" {
          Direct traffic to pool member 2
        persist source_addr 
    session add source_addr [IP::client_addr] 10.75.65.56 3600
      }
      default {
      }
   }
}

/persist1 and /persist2 do not exist. My thinking was that I could use that as a switch to drive the switch logic, but I'm sure I'm doing something wrong. Ideally, the customer would like to send a string that sets persistence to a selected node for an hour to allow them to perform testing against that node. Has anyone done this before?

 

Thanks in advance for any help

 

2 Replies

  • Hi,

    you can use the following irule:

    when CLIENT_ACCEPTED { 
        set default_pool [LB::server pool]
    }
    
    when HTTP_REQUEST {
        set target_member [URI::query [HTTP::uri] server]
        if {!($target_member eq "")} {
            pool $default_pool member $target_member
            HTTP::uri [string map -nocase [list "&server=$target_member" "" "?server=$target_member" "" ] [HTTP::uri]]
        }
    }
    

    Then, the developer may append parameter server=1.2.3.4 for the first request, then the default persistence profile will be used to persist for next requests.