John_LeMay_1062
Apr 08, 2008Nimbostratus
Improving on this "catch all"?
Recently I configured a "catch all" type virtual server and I'm handling various aspects of traffic management with an iRule. So far it's working well, but it is already becoming difficult to manage. The rule follows and should be, I believe, relatively self-explanatory except for the "matchclass" statement. That statement is used to differentiate between internal and external clients, redirecting the external clients to a separate pool of servers.
I was hoping for some tips on improving this concept to make it easier on the eyes and simpler to manage going forward. I'm also concerned about performance as this rule continues to grow as we utilize it for additional sites. Host names and other info have been made more generic for the sake of posting here.
when HTTP_REQUEST {
if { [HTTP::host] equals "site1.domain.com" }{
pool pool_site1.domain.com
} elseif { [HTTP::host] equals "site2.domain.com" }{
if { [HTTP::uri] eq "/" }{
HTTP::uri "/pathtosite/site2"
}
if { [matchclass [IP::client_addr]/16 equals $::mySubnets] }{
pool pool_site2.domain.com_internal
} else {
pool pool_site2.domain.com
}
} elseif { [HTTP::host] equals "site3.domain.com" }{
pool pool_site3.domain.com
} else {
reject
}
}