TMcGov_92811
Jan 23, 2009Nimbostratus
Using matchclass to check Source IP with HTTP_REQUEST?
F5 Posting
Hi,
With this iRule I am hoping to direct certain Source IP addresses to Pool-A while directing other HTTP Requests based on URIs to other pools. The syntax is valid, but the iRule doesn't work for any of the conditions. If I remove the first "matchclass" portion the rest of the iRule works. I suspect that using "matchclass" to inspect a client_addr doesn't work with the "HTTP_REQUEST" event. But when I tried to nest the HTTP_REQUEST as part of the original CLIENT_ACCEPTED (in order to use matchclass successfully) the syntax was marked invalid. Will I need two seperate IRules to accomplish this ? One with
the "CLIENT_ACCEPTED" event then a second with the "HTTP_REQUEST" event ?
Combined iRule that doesn't work:
when HTTP_REQUEST {
if { [matchclass $::testips contains [IP::client_addr]] } {
pool poolA
} else {
if { [HTTP::uri] contains "/cf/" or [HTTP::uri] contains "/hf/"} {
pool poolB
} elseif {
[HTTP::uri] contains "/asweb/"} {
pool poolC
} elseif {
[HTTP::uri] contains "/vh/"} {
pool poolD
} else {
pool poolE }
}
}
Individual ones that work seperately:
********************************************************************************
when HTTP_REQUEST {
if { [HTTP::uri] contains "/cf/" or [HTTP::uri] contains "/hf/"} {
pool poolB
} elseif {
[HTTP::uri] contains "/asweb/"} {
pool poolC
} elseif {
[HTTP::uri] contains "/vh/"} {
pool poolD
} else {
pool poolE }
}
}
********************************************************************************
when CLIENT_ACCEPTED {
if { [matchclass $::testips contains [IP::client_addr]] } {
pool poolA
} else {
pool poolE }
}