14-Sep-2021
07:28
- last edited on
05-Jun-2023
23:02
by
JimmyPackets
Hello
Kindly i need to apply Session Persistence based on http header :
Payment application working as follow:
I want to make sure that the client land on the same server that sent the "X-Token"
I searched for iRule that match the http header, the following iRule will work or need to modify it?
when HTTP_REQUEST {
if { [HTTP::header exists "X-Auth-Token"]} {
persist uie [HTTP::header "X-Auth-Token"]
}
}
Q
Solved! Go to Solution.
15-Sep-2021 21:23
when HTTP_RESPONSE {
if { [HTTP::header exists "X-Token"] } {
if { [HTTP::header "X-Token"] != "" } {
persist add uie [HTTP::header "X-Token"]
}
}
}
when HTTP_REQUEST {
if { [HTTP::header exists "X-Auth-Token"] } {
set value [persist lookup uie [HTTP::header "X-Auth-Token"]]
log local0. "value is $value"
if { $value != "" } {
persist uie [HTTP::header "X-Auth-Token"]
}
}
}
14-Sep-2021 11:44
Hi Mohanad,
Your irule seems correct. Maybe you can add a fallback persistence in an else condition.
According to the article (Overview of universal persistence (f5.com), in addition to your irule, you should also create a universal persistence profile as follows:
To create a universal persistence profile and reference the persistence iRule you created in the previous procedure, perform the following procedure:
15-Sep-2021 05:15
Thank you Oguzy, i know this requires persistence profile
15-Sep-2021 21:23
when HTTP_RESPONSE {
if { [HTTP::header exists "X-Token"] } {
if { [HTTP::header "X-Token"] != "" } {
persist add uie [HTTP::header "X-Token"]
}
}
}
when HTTP_REQUEST {
if { [HTTP::header exists "X-Auth-Token"] } {
set value [persist lookup uie [HTTP::header "X-Auth-Token"]]
log local0. "value is $value"
if { $value != "" } {
persist uie [HTTP::header "X-Auth-Token"]
}
}
}
16-Sep-2021 05:49
Thank you so much xuwen, i will test it out and feedback
16-Sep-2021 07:10
working successful! thank you so much xuwen