Forum Discussion
xuwen
Jul 20, 2022Cumulonimbus
plan C:
Creating the universal persistence profile
To create a universal persistence profile and reference the persistence iRule you created in the previous procedure, perform the following procedure:
- Log in to the Configuration utility.
- Navigate to Local Traffic > Profiles.
- From the Persistence menu, click Create.
- Type a name for the universal persistence profile.
- For Persistence, click Universal.
- For Configuration, select the iRule check box, then click the persistence iRule you created.
- Click Finished.
iRules code:
when HTTP_RESPONSE priority 500 {
if { [HTTP::cookie exists "JSESSIONID"] } {
# serverID0,serverID1, length is 9
set node_x [findstr [HTTP::cookie "JSESSIONID"] "serverID" 0 9]
log local0. "node_x is $node_x"
# persist add uie, key is serverIDX, timeout is 1800s
persist add uie $node_x 1800
}
}
when HTTP_REQUEST priority 500 {
if { [HTTP::cookie exists "JSESSIONID"] } {
set server_x [findstr [HTTP::cookie "JSESSIONID"] "serverID" 0 9]
set value [persist lookup uie $server_x]
if { $value != "" } {
persist uie $server_x
}
}
}