Forum Discussion
Mike_Young_6152
Nimbostratus
Jan 17, 2013iRule for selecting a pool based on a cookie value not working
I need to redirect traffic based on a cookie.
when HTTP_REQUEST {
if{([HTTP::cookie exists "asv"]) and ([HTTP::cookie value "asv"] eq "1" )}{
pool web_new_version_pool
}
else{
pool web_pool
}
}
The cookie should contain a number like asv=1
By the science of deduction I narrowed it down to the and ([HTTP::cookie value "asv"] eq "1" ) part but I just can't see what is wrong with the syntax.
Any ideas would be greatly appreciated.
3 Replies
- nitass
Employee
do you have tcpdump or log showing bigip sending traffic to wrong pool?
e.g.[root@ve10:Active] config b virtual bar list virtual bar { snat automap 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 HTTP_REQUEST { set uri [HTTP::uri] set cookie [HTTP::cookie value "asv"] if { $cookie eq "1" } { pool new_foo } else { pool foo } } when HTTP_RESPONSE { log local0. "client [IP::client_addr]:[TCP::client_port] | uri $uri | cookie $cookie | pool [LB::server pool] | server [IP::remote_addr]:[TCP::remote_port]" } } [root@ve10:Active] config b pool foo list pool foo { min active members 1 members 200.200.200.101:80 {} } [root@ve10:Active] config b pool new_foo list pool new_foo { members 200.200.200.111:80 {} } [root@ve10:Active] config tail -f /var/log/ltm Jan 18 04:11:56 local/tmm info tmm[4884]: Rule myrule : client 172.28.19.251:46804 | uri / | cookie 1 | pool new_foo | server 200.200.200.111:80 Jan 18 04:12:22 local/tmm info tmm[4884]: Rule myrule : client 172.28.19.251:46805 | uri /something | cookie 99 | pool foo | server 200.200.200.101:80 - Mike_Young_6152
Nimbostratus
Well I think I found most of the problem was just whitespace... gets me everytime. To answer your question I don't have acces to the logs.when HTTP_REQUEST { if { [HTTP::cookie exists "asv"] and [HTTP::cookie value "asv"] eq "2" }{ pool web_new_version_pool } else { pool web_pool } } - giltjr
Nimbostratus
I'm not sure what is going on, but I think you have made some assumptions in your iRule that may not valid.
On the 1st HTTP_REQUEST there should be NO cookie asv, so everything should end up getting assigned to pool "foo" to start.
The 1st response from the server should set the cookie asv.
So by the time the cookie is set, the pool has been assigned and things could be getting messed up from there.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects