Cookie persistence via iRule
I've read a few articles about accomplishing this but nothing that has really suited my needs so far.
At a high level, we have a 'shared' vserver that we use for multiple services. We load balance to the appropriate pools using an iRule based on URIs. We’d like to explore the possibility of creating a new iRule that will match on a specific URI (for now - eventually we'll want to class match to a datagroup) and implement cookie persistence if it matches. Otherwise, just continue to process the other iRules in the stack.
I'd like something similar to the following. This doesn't work with cookie persistence but DOES work with source address:
when HTTP_REQUEST {
if { ([HTTP::path] contains "/xyz/") } { persist cookie }
}
We get the following error message when applying the iRule to the vserver:
01070372:3: Persistence mode (Cookie) called out in rule (/Common/test_cookie_persistence) requires a corresponding persistence profile for virtual server (/Common/pool_name).
However, a similar iRule using source address persistence doesn't require an persistence profile on the virtual server:
when HTTP_REQUEST {
if { ([HTTP::path] contains "/xyz/") } { persist source_addr }
}
Can anybody shed some light on why this is? Or point me in the right direction of an example of a working cookie persistence iRule that doesn't require the need for the persistence profile to be applied? The whole point of the iRule would be to avoid the persistence profile which would then apply to all services using this vserver, so applying one in this case kind of defeats the purpose.