Forum Discussion
Kris__109062
Nimbostratus
Oct 31, 2008iRule to Select alternate pool member based on QUERY_STRING
Hi,
I have the following iRule setup (define_node) which allows me to force a pool member to be selected if I add ?node=01 , ?node=02 & ?node=03 to the query string..
Now the rule works and I am presented to the correct node but my problem is that subsequent requests do not persist if I take off ?node=01 from the QUERY_STRING
ie. http://intranet/?node=01 binds me to member 192.168.49.97 which is correct if you follow the irule logic below but subsequent requests eg. http://intranet/ might take me to other members in the pool.
How do I make it so that once ?node=01 is executed my persistence stays on that node ?
Irule (define_node)..
when HTTP_REQUEST {
set default_pool [LB::server pool]
set thenode [ findstr [string tolower [HTTP::uri]] "node=" 5 2]
if { $thenode == "01" } {
pool $default_pool member 192.168.49.97
}
if { $thenode == "02" } {
pool $default_pool member 192.168.49.98
}
if { $thenode == "03" } {
pool $default_pool member 192.168.49.99
}
}
virtual intranet_80 {
pool pool_intranetapp_80
destination 192.168.48.25:http
ip protocol tcp
vlans external_480 enable
rules
define_node
profiles
http
tcp
persist source3600
}
pool pool_intranetapp_80 {
lb method member observed
monitor all http_80
members
192.168.49.97:http
192.168.49.98:http
192.168.49.99:http
}
profile persist source3600 {
defaults from source_addr
mode source addr
timeout 3600
}
4 Replies
- hwidjaja_37598
Altostratus
Try this out:when HTTP_REQUEST { set persistTo [session lookup \ source_addr [IP::client_addr]] set default_pool [LB::server pool] set timeOut 3600 switch [ findstr [string tolower \ [HTTP::uri]] "node=" 5 2] { 01 { set persistTo 192.168.49.97 } 02 { set persistTo 192.168.49.98 } 03 { set persistTo 192.168.49.99 } } if {$persistTo eq ""} { pool $default_pool } else { pool $default_pool member $persistTo session add source_addr [IP::client_addr] \ $persistTo $timeOut } }
- Kris__109062
Nimbostratus
Hi hwidjaja, - hwidjaja_37598
Altostratus
Hello Kris, - aaronactive_227
Nimbostratus
Hi There,
Has something changed since this used to worK?
Just trying it out now and I get this message when trying to save the iRule:
01070151:3: Rule [Define_Persist_Member] error: line 2: [wrong args] [session lookup \ ] line 3: [undefined procedure: source_addr] [source_addr [IP::client_addr]]
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