Forum Discussion

nrelihan_68143's avatar
nrelihan_68143
Icon for Nimbostratus rankNimbostratus
Aug 02, 2011

Must the iRule always select a pool?

Hey,

 

 

In my iRule I plan to use two pools, pool_bots and pool_default. Bot and crawler traffic will be sent to pool_bots and pool_default wil be used for all other traffic.

 

So just to be clear can I put this iRule on a virtual server that is pointing towards pool_default so I dont have to put in the line "pool pool_default" in the switch statment code?

 

Im just not 100% on the mechanics of the F5 Im afriad.

 

Thanks,

 

 

Neil

 

 

 

 

when HTTP_REQUEST {

 

set hostname [string tolower [HTTP::host]]

 

set uri [string tolower [HTTP::uri]]

 

if { [matchclass [string tolower [HTTP::header User-Agent]] contains $::bots] } {

 

pool pool_bots}

 

else {

 

 

switch [whereis [IP::client_addr]] {

 

 

"IE" {

 

if {$hostname eq "www.example.com" and not $uri starts_with "/ireland"} {

 

HTTP::redirect http://www.example.com/ireland/[HTTP::uri] } }

 

 

"GB" {

 

if {$hostname eq "www.example.com" and not $uri starts_with "/ireland" } {

 

HTTP::redirect http://www.example.co.uk/[HTTP::uri]

 

}

 

}

 

default {

 

if {$hostname eq "www.example.com" and not $uri starts_with "/ireland" } {

 

HTTP::redirect http://www.example.com/region-selectpage}

 

}

 

}

 

}
  • You are correct.

     

     

    The default behavior for all traffic not matched in the iRule would be directed to the pool assigned to the Virtual Server that the iRule was applied on.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    A small note: if you're on 9.4.4 or higher, you should remove the $:: prefix from the datagroup name. Pre-v10 this was a best practice, but in v10 and higher, it's a requirement for the rule to work.

     

     

    http://devcentral.f5.com/wiki/iRules.CMPCompatibility.ashx

     

     

    Aaron