Forum Discussion
http cookie persistence
I have an application . When users makes a connection for the first time , server hands over a cookie to the user , when the user comes with the same cookie traffic should go to the same backend node which handed over the cookie.
If the cookie value is session1 , request need to go to node1, If cookie value is session2 request need to go to node2. This is the logic i am trying to work on , it would great help if i can get an irule for this .
when HTTP_REQUEST {
if { [HTTP::cookie exists "SESSION1"] } {
node 1
} else {
if { [HTTP::cookie exists "SESSION2"] } {
node 2
}
else pool default pool
}
}
- Sam10
Altostratus
Bellow are the 2 irules i tried an no luck ,experts any help on this .
when HTTP_REQUEST {
if { [HTTP::cookie exists "EO_SESSION_ID"] } {
persist uie [HTTP::cookie "EO_SESSION_ID"] 3600
} else {
set jsess [findstr [HTTP::uri] "EO_SESSION_ID" 1 ";"]
if { $jsess != "" } {
persist uie $jsess 3600
}
}
}
when HTTP_RESPONSE {
if { [HTTP::cookie exists "EO_SESSION_ID"] } {
persist add uie [HTTP::cookie "EO_SESSION_ID"] 3600
}
}
Tried even with switch statement.
when HTTP_REQUEST {
switch [string trimleft [HTTP::cookie EO_SESSION_ID] cookie] {
"cookie1" {
pool prod-pool member 192.168.1.1 5700
}
"cookie2" {
pool prod-pool member 192.168.1.2 5700
}
default {
pool prod-pool
}
}
}
Instead of irule can i use cookie hash persistence.
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