Forum Discussion

Randy_Johnson_1's avatar
Randy_Johnson_1
Icon for Nimbostratus rankNimbostratus
Feb 08, 2006

Newbie to IRules - HELP PLEASE !

Hi group -

 

This is my first venture into the world of IRules, and I'm hoping for some direction.

 

The basic situation is this -

 

I have a webfarm runing several applications. Some of these applications, we get paid for, and one we do not. The one app we don't get paid for is processor intensive, so I'd like to redirect requests for this app to a single machine in the farm.

 

My apps are all called via HTTPS, and the SSL connection is terminated at the BigIP.

 

 

Can I use something as simple as

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "AddressSvc" } {

 

pool address_pool

 

}

 

}

 

 

And the BigIP will know what to do with the request if it does NOT contain the string

 

AddressSvc"AddressSvc"?

 

Or do I need 'Else' cases as well ? This would make the IRule considerably more ... painful, as there are MANY 'good' URLs that may be directed to any of several pools

 

 

Thanks, all !!

7 Replies

  • You can leave it at that as long as all your other urls are going to a single pool. If you need to filter out more urls to different pools (as it seems from your post), then you'll have to account for them in the rule (or use multiple virtuals with a single pool on each).

     

     

    The best way to approach this is to set the default pool for the virtual to the one that covers most cases and then add code to the iRules to override the behavior for the less frequent cases. Since I don't know your configuration, I can't really help out any more with optimization tips.

     

     

    If you have a large number of urls, you can also look at storing the groups of urls into external classes (or data groups) and then use those groups in conjuction with the "matchclass" command. You can search the forums or wiki for examples of using that command. This is really only useful when dealing with a large number of comparisons.

     

     

    -Joe

     

  • Then it really is as simple as you thought. You might want to force the uri to lower case to handle "address", "Address", "ADDRESS", etc though...

    when HTTP_REQUEST {
      if { [string tolower [HTTP::uri]] contains "address" } {
        pool address_pool
      }
    }

    This way requests with URI's containing "address" (case insensitive), will get routed to the address_pool, while all other requests will get routed to the default pool for the given virtual.

    -Joe
  • Very good !

     

    One more question then...In this Irule:

     

    when HTTP_REQUEST {

     

    if { [string tolower [HTTP::uri]] contains "address" } {

     

    pool address_pool

     

    }

     

    }

     

     

    Is the pool 'address_pool' a literal ? I mean, the pool 'name' is actually 'address_pool' and it doesn't need to be assigned to the VS, Big IP knows to send the traffic to that pool based on it's name ?

     

     

    Thanks for all the help !!

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    That's correct, the pool command takes an argument that is either a literal pool name, or a variable with a value that is the name of a valid pool.

     

     

    This is independant from the Virtual Server configuration.

     

     

    -Colin
  • Okay then, looks like I'm set... I'd like to log this stuff too... how does this look ?

     

     

     

    when HTTP_REQUEST {

     

    log local0. "checking URI for Address validation only calls"

     

    if { [string tolower [HTTP::uri]] contains "addresssvc.asmx" } {

     

    log local0. "Request from [IP::client_addr] is being sent to the Address Service" pool address_pool

     

    }

     

    }
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    That looks really close. I'd make one small change and move the pool command to its own line, like this:

    
    when HTTP_REQUEST {
      log local0. "checking URI for Address validation only calls"
      if { [string tolower [HTTP::uri]] contains "addresssvc.asmx" } {
        log local0. "Request from [IP::client_addr] is being sent to the Address Service" 
        pool address_pool
      }
    }

    -Colin
  • LOL

     

    Okay, I hope this is really my last question, and I can quit bugging y'all -

     

    Reading the Docs regarding IRules, it says that if I am going to use the event HTTP_REQUEST, the n the VS the rule is assigned to must reference an http profile type.

     

     

    Currently, all VSs reference a 'SSL Profile (Client) called client ssl.

     

    Can I add a http profile to the VSs and not break my VS setup ? Can a VS reference multiple profile types, and does one take precedence over the others ?

     

     

    Thanks again, you guys have been awesome, with extremely timely and informative answers!