I’m trying to implement an iRule from wiki article at:
https://devcentral.f5.com/wiki/irul…tence.ashx
I am pretty new at iRules and I’m missing something, so I apologize in advance for my ignorance.
I have the following setup:
Virtual Server vs_MyTwoServers
Default Pool Pool_MyTwoServers
Persistence Profile mySiteCookie Parent profile: cookie Cookie Method: Http Cookie Insert Cookie Name: PersistCookie8hrs
Nodes: 10.6.0.68:80 (Server7910) 10.6.0.68:80 (Server7911)
I want to be able to add a uri query of and have that session traffic only go to Server7910
I’ve setup a data group list called my_forced_nodes:
Data Group List Name: my_forced_nodes
Type: String
String Records:
7910 := 10.6.0.68 80
7911 := 10.6.0.69 80
iRule from wiki article with my information in it:
-----------------------------------------------------------------------------
when RULE_INIT {
set cookie_name “my_node_forced”
}
when HTTP_REQUEST {
Get node id from URL ending in ?node=server1, ?node=server2, etc.
set node_forced [findstr [HTTP::uri] “?node=” 6]
Or from previous cookie
set has_cookie [HTTP::cookie exists $::cookie_name]
if { $node_forced eq “” and $has_cookie } {
set node_forced [HTTP::cookie value $::cookie_name]
}
Map node id to IP and port found in a class
Entries should be strings of the form
if { $node_forced ne “” } {
set node_data [findclass $node_forced $::my_forced_nodes " "]
if { $node_data ne “” } {
set node_ip [getfield $node_data " " 1]
set node_port [getfield $node_data " " 2]
pool Pool_MyTwoServers member $node_ip $node_port
} else {
set node_forced “”
}
}
}
when HTTP_RESPONSE {
if { $node_forced ne “” } {
Add a cookie to continue forcing node assignment
HTTP::cookie insert name $::cookie_name value $node_forced path “/”
}
elseif { $has_cookie } {
Delete cookie and resume load balancing (with built-in persistence)
HTTP::cookie insert name $::cookie_name value “” path “/”
HTTP::cookie expires $::cookie_name 0 absolute
}
}