Forum Discussion

Joe_Curl_105786's avatar
Joe_Curl_105786
Icon for Nimbostratus rankNimbostratus
Mar 31, 2010

iRule Pool Selection

We have an iRule that we use to restrict access to only specific URI patterns. If the pattern is matched, then we select a pool. I was wondering if there is any way to tell it to select the pool that is tied to the specific VIP instead of creating this rule multiple times, and just changing the pool name. The pool name NRDC-PK-Mobility-QA-Pool is the name of the pool associated with the VIP. We are trying to make it more generic so we can use this single rule in many instances. Any assistance is appreciated. I have put an example of the rule below.

 

 

Joe

 

 

when HTTP_REQUEST {

 

if { ( [string tolower [HTTP::uri]] starts_with "/transportservlet" ) or ( [string tolower [HTTP::uri]] starts_with "/aliveservlet" ) } {

 

pool NRDC-PK-Mobility-QA-Pool

 

} else {

 

reject

 

}

 

}

1 Reply

  • Hi Joe,

    I think you can rewrite it to the following:

      
      when HTTP_REQUEST { 
          From the client side context it's going to determine the VIP address it's connected to  
         if {[IP::addr [IP::local_addr] eq "192.168.12.3" } {  
              switch -glob [string tolower [HTTP::uri]] {  
                "/transportservlet*" -  
                "/aliveservlet*"  { pool NRDC-PK-Mobility-QA-Pool }  
                default { reject }  
             }  
         }  
      }  
      

    I reworked the HTTP::uri evaluation to use SWITCH because it it's more efficient then IF-ELSE.

    I hope this helps

    Bhattman