cancel
Showing results for 
Search instead for 
Did you mean: 

Specifying pool in iRule failing

I have an iRule here and when I hit up the VIP that has this rule applied, it does not seem to work at all:

 

 

when CLIENT_ACCEPTED {

 

 

Save default pool name

 

set default_pool [LB::server pool]

 

}

 

 

when HTTP_REQUEST {

 

log local0. "[HTTP::uri] [LB::server addr]"

 

if { [HTTP::uri] ends_with "test=64" }{

 

pool test-temp

 

} elseif { [HTTP::uri] contains "test=64&" }{

 

pool test-temp

 

} else {

 

pool $default_pool

 

}

 

}

 

 

 

I tried shutting down the default_pool servers, and instead of going to test-temp pool, I just get a connection refused. I tried setting persistence to NONE. What am I missing here?

 

 

I'm calling http://my.vip.ip.here/test.txt?test=64

 

I have a similar iRule applied for HTTP::path rather than HTTP::uri for image extensions which seems to work fine. Bottom line I need to get people going to our domain with test=64 anywhere in the URI to a different group of servers. Thanks.

 

5 REPLIES 5

What_Lies_Bene1
Cirrostratus
Cirrostratus
I'd suggest you drop the code in CLIENT_ACCEPTED and just configure a default Pool with the VS. You are using a command that returns a value only after a Pool is selected in an event that precedes the event you are selecting a Pool in; it's a bit back to front.

If I remove that, it still does not seem to work. For example, I've tried using only:

 

 

when HTTP_REQUEST {

 

log local0. "[HTTP::uri] [LB::server addr]"

 

if { [HTTP::uri] ends_with "test=64" }{

 

pool test-temp

 

} elseif { [HTTP::uri] contains "test=64&" }{

 

pool test-temp

 

}

 

}

 

 

It still only goes to the default pool.....

 

 

I'm confused ,as you can see I'm logging the HTTP::uri and it is exactly what is in the condition, yet it seems to be ignored???

What_Lies_Bene1
Cirrostratus
Cirrostratus
Can you provide some log output please, for verification. Also, you are slightly back to front;

 

when HTTP_REQUEST { if { [HTTP::uri] ends_with "test=64" }{ pool test-temp } elseif { [HTTP::uri] contains "test=64&" }{ pool test-temp } log local0. "[HTTP::uri] [LB::server addr]" }

nitass
F5 Employee
F5 Employee
how did you know it goes to default pool? if there are number of requests (e.g. object inside web page), only the one containing "test=64" in request will go to test-temp pool.

 

 

[root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.252:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { set host [HTTP::host] set uri [HTTP::uri] if { [HTTP::uri] ends_with "test=64" }{ pool test-temp } elseif { [HTTP::uri] contains "test=64&" }{ pool test-temp } else { pool $default_pool } } when HTTP_RESPONSE { log local0. "client [IP::client_addr]:[TCP::client_port] | host $host | uri $uri | pool [LB::server pool] | server [IP::server_addr]:[TCP::server_port] | status [HTTP::status]" } } [root@ve10:Active] config b pool test-temp list pool test-temp { members 200.200.200.111:80 {} } log [root@ve10:Active] config tail -f /var/log/ltm May 1 09:14:38 local/tmm info tmm[4950]: Rule myrule : client 172.28.20.17:60149 | host my.vip.ip.here | uri /test.txt?test=64 | pool test-temp | server 200.200.200.111:80 | status 404

Kevin_Stewart
F5 Employee
F5 Employee
If I may interject with a few comments, to Steve's original statements, when used in CLIENT_ACCEPTED, the [LB::server pool] command returns the default pool of the VIP before it could have been changed by an iRule, HTTP class or other method. It's also good practice to use this structure when doing this kind of dynamic, real-time pool selection because pool selection is generally "sticky" within a TCP session. In other words, if multiple HTTP requests come through a single TCP session, a single pool statement will force all subsequent requests down that path. You might also be experiencing, as Nitass suggests, multiple requests for different objects within the page that don't meet your pool selection criteria.

 

 

Please try this modified version of your iRule and review/report the results:

 

 

when CLIENT_ACCEPTED { set default_pool [LB::server pool] log local0. "default pool = $default_pool" } when HTTP_REQUEST { log local0. "uri = [string tolower [HTTP::uri]]" if { [string tolower [HTTP::uri]] ends_with "test=64" }{ log local0. "first condition" pool test-temp } elseif { [string tolower [HTTP::uri]] contains "test=64&" }{ log local0. "second condition" pool test-temp } else { log local0. "default condition" pool $default_pool } }