combine irules for LB by client IP and then http hostname

Hi,

I want to LB a certain range of source IP to a particular pool, else forward all other traffic to another irule that will LB by hostname. When i apply both irules, it also go the the second one. How to it fix this and is it possible to combine both irules to one?

First irule-LB by source IP:

when CLIENT_ACCEPTED {

if { [matchclass [IP::client_addr] equals $::Sharepoint_SrcIP_Allowed] }{

Uncomment the line below to turn on logging.

log local0. “Connection accepted from [IP::client_addr]:[TCP::local_port] to tcp port [TCP::remote_port]”

pool sharepoint

}

}

----above irule sends client matching Sharepoint_SrcIP_Allowed" Datagroup to pool “sharepoint”--

2nd Irule - LB by hostname:

when HTTP_REQUEST {

if { [HTTP::host] eq “itportal” } {

pool itportal }

elseif { [HTTP::host] eq “espportal” }{

pool espportal }

elseif { [HTTP::host] eq “mysite” }{

pool mysite }

elseif { [HTTP::host] eq “qaportal” }{

pool qaportal }

elseif { [HTTP::host] eq “sharepointssp” }{

pool sharepointssp }

elseif { [HTTP::host] eq “portal” }{

pool portal_sharepoint }

}

----

If I either one, it works fine but when I apply both, it always process the 2nd irule even when i matches the first one. Any advice?

Hi Steve,

I believe you can rewrite it to the following

when HTTP_REQUEST {  
    if { [matchclass [IP::client_addr] equals $::Sharepoint_SrcIP_Allowed] }{  
      pool sharepoint  
    } else {  
       switch -glob [HTTP::host] {  
         "itportal" { pool itportal }  
         "esportal" { pool esportal }  
         "mysite" { pool mysite }  
         "qaportal" { pool qaportal }  
         "sharepointssp" { pool sharepointssp }  
         "portal" { pool portal_sharepoint }  
       }  
    }  
  }

I hope this helps

Bhattman

yes! Thanks! This forum is awesome!

Glad to be of some assistance

Bhattman