Frankx
Jan 31, 2017Altocumulus
Persistence iRule for Airwatch
I've been asked to write an iRule using CARP persistence and based on awcmsessionid. Found this on DevCentral and it was all I could find was wondering if anyone can tell if this works and/or have an iRule that does work. Thanks, Frank.
when HTTP_RESPONSE { Check the awcmsessionid header exists if { [HTTP::header exists "awcmsessionid"] } {
If it does, check it has a usable value
if { [HTTP::header value "awcmsessionid"] != "" } {
If it does, use it to create a persistence record
persist add uie [HTTP::header value "awcmsessionid"] 1800
}
else {
log local0. "The awcmsessionid HTTP header was found but is null"
No luck then, will need to rely on request query string if we can
}
}
If no header found log local0. "The awcmsessionid HTTP header was not found" }
when HTTP_REQUEST { Check the awcmsessionid header exists if { [HTTP::header exists "awcmsessionid"] } {
If it does, check it has a usable value
if { [HTTP::header value "awcmsessionid"] != "" } {
If it does, use it to do a persistence lookup
If you need to select a pool, do so here, before we persist
persist uie [HTTP::header value "awcmsessionid"] 1800
exit here to ensure we don't do two persistence lookups
return
}
else {
log local0. "The awcmsessionid HTTP header was found but is null"
No luck then, will need to rely on request query string
}
}
No header so lets use the HTTP query instead, if we can Check the right string exists if { [string tolower [HTTP::query ]] contains "awcmsessionid" } {
The required query string is there, let's get it's value
We'll find awcmsessionid, move one to the right (the =)
and store data to the end of the query in our variable
set querystring [findstr [HTTP::query] "awcmsessionid" "1"]
Lets check its not null
if { $querystring != "" } {
persist uie $querystring 1800
}
else {
log local0. "No header or relevant query string found - can't persist"
}
}
}