Forum Discussion
torisan_93696
Nimbostratus
Apr 10, 2007Feasibility : Session Persistence based on URI parameters
Hi,
being new to F5 devices and iRules I have the following use case + question(s):
Use Case: We want to load balance requests (simple RR) but have session stickyness (persistence)...
torisan_93696
Nimbostratus
Apr 10, 2007Hi,
thanks for replying. In the meantime I have come with something like the following:
1. did an iRule with persist uie "my session key"
2. setup persistence profile referencing this iRule and assigned this persistence profile a primary profile to my virtual server.
So, please don't waste to much of you time ...
However, do you happen to know how the scoping and durability of variables is handled?
I can access a variable assigned with set xyz "value" in all events in an iRule - the events occur in a certain sequence probably (down the protocol stack on request, up the stack on response I guess, but the precise sequence is not clear), so if I assign a variable in HTTP_REQUEST, it is already filled in LB_SELECTED (which is OK for me). The same seems to hold for ::xyz - I believe the "::" notation is something like global in TCL, right?
--- Code for the iRule I used ---
when HTTP_REQUEST {
Sticky Sessions for WF Connect based on URI parameters on URIs starting with the /extern infix
if { [HTTP::uri] starts_with "/extern" } {
set username ""
set password ""
set account ""
this access to parameters will work also in pre 9.2 big ip systems
log local0. "HTTP::query: [HTTP::query]"
set namevals [split [HTTP::query] "&"]
for {set i 0} {$i < [llength $namevals]} {incr i} {
set params [split [lindex $namevals $i] "="]
set pnum [expr $i+1]
if { [lindex $params 0] == "account" } {
set account [lindex $params 1]
}
if { [lindex $params 0] == "username" } {
set username [lindex $params 1]
}
if { [lindex $params 0] == "password" } {
set password [lindex $params 1]
}
}
set ::persistenceKey "$account-$username-$password"
this will only work in 9.2 and later version of big ip
set persistenceKey [md5 "[URI::query [HTTP::uri] "account"]-[URI::query [HTTP::uri] "username"]-[URI::query [HTTP::uri] "password"]"]
persist uie $persistenceKey
log local0. "wf connect request (/extern) using session persistence key: $persistenceKey"
}
}
Just to check - output result of node assigment to log
when LB_SELECTED {
log local0. "wf connect request (/extern) directed to [LB::server addr] for persistenceKey $persistenceKey"
}
Maybe it helps someone else as well.
Toralf
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
