I have a Virtual server which will get http requests like this http://mysite.com/login?id=xyz-1, http:://mysite.com/login?id=xyz-2.
I want the iRule to inspect the parameters and if the last digit of the parameter id is 1 select pool 1. If it is 2 select pool 2. I also want the subsequent requests to be persistent.
Thanks for such a quick response. This is great help. Now if I remember right, to use cookie persistence where the pools foo1 and foo2 have different members, I need to use oneconnect as well on the virtual server. Do you agree?
Also what will be the difference in setting cookie after the parameter matches, instead of defining it at the virtual server definition?
Now if I remember right, to use cookie persistence where the pools foo1 and foo2 have different members, I need to use oneconnect as well on the virtual server. Do you agree? are you talking about this one?
sol9800: Using an iRule to load balance HTTP requests to multiple pools
well, i think using oneconnect is fine.
Also what will be the difference in setting cookie after the parameter matches, instead of defining it at the virtual server definition? i got an error.
[root@ve1024:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
if { [HTTP::query] ends_with "1" } {
persist cookie
pool foo1
} elseif { [HTTP::query] ends_with "2" } {
persist cookie
pool foo2
} else {
pool foo
}
}
when SERVER_CONNECTED {
log local0. "[IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] -> [IP::remote_addr]:[TCP::remote_port]"
}
}
[root@ve1024:Active] config b virtual bar list
virtual bar {
snat automap
destination 172.28.19.79:80
ip protocol 6
profiles {
http {}
tcp {}
}
}
[root@ve1024:Active] config b virtual bar rule myrule
BIGpipe unknown operation error:
01070372:3: Persistence mode (Cookie) called out in rule (myrule) requires a corresponding persistence profile for virtual server (bar).
You might want to check the specific parameter value to see if it ends in 0 or 1 instead of the full query string to be more exact. You can use [URI::query [HTTP::uri] id] to get the id parameter value.
And if subsequent requests don’t have that parameter set and you still want to persist clients to the prior pool, you will probably want to set a cookie to track when a pool selection has been made and then look for that cookie on requests without the id parameter.