Forum Discussion
Cookie persistence via iRule
Thanks for again for the help so far.
I think I was overcomplicating this by assuming a default cookie persistence profile would take precedence over desired persistence behavior set in an iRule (specifically that the default persistence profile would be applied before parsing through the iRules). Looks like that was incorrect, but please correct me if I'm wrong.
Using a configuration similar to what's below seems to work. With this, a cookie will only be set if you're hitting a URI of either /xyz/ or /abc/. Anything else won't use persistence (note the fallback persistence profile for source_addr shouldn't be required on the vserver).
Keep in mind this is config from a device on 11.4.1.
ltm data-group internal /Common/cookie_uris_datagroup {
records {
/xyz/ { }
/abc/ { }
}
type string
}
ltm rule /Common/set_cookie_persistence {
when HTTP_REQUEST {
if { [ class match [HTTP::uri] contains cookie_uris_datagroup ] }
{ persist cookie }
else
{ persist none }
}
ltm virtual /Common/my_server {
destination /Common/192.168.1.100:80
fallback-persistence /Common/source_addr
ip-protocol tcp
mask 255.255.255.255
persist {
/Common/cookie {
default yes
}
}
profiles {
/Common/http { }
/Common/tcp { }
}
rules {
/Common/set_cookie_persistence
}
source 0.0.0.0/0
source-address-translation {
type automap
}
translate-address enabled
translate-port enabled
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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