Forum Discussion
jwhite18
Nimbostratus
May 25, 2016Irule Integration
Hi guys,
I have this irule:
when HTTP_REQUEST {
switch [HTTP::cookie hectorlbhkg] {
-
-
{
pool [HTTP::cookie hectorlbhkg]
set selected ""
}
default {
...
Stanislas_Piro2
Cumulonimbus
May 25, 2016Hi,
your "new" irule is not working.
The condition must be:
([string tolower [HTTP::header User-Agent]] contains "msie7") or ([string tolower [HTTP::header User-Agent]] contains "msie8")
And you can optimize the irule like that:
when RULE_INIT {
array set static::pools {
0 "www.hector.com_cluster_2a"
1 "www.hector.com_cluster_2b"
2 "www.hector.com_cluster_2c"
}
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::header User-Agent]] contains "msie7") or ([string tolower [HTTP::header User-Agent]] contains "msie8") } {
pool www.hector.com_cluster_2k
} elseif { [info exists static::pools([HTTP::cookie hectorlbhkg])]} {
pool $static::pools([HTTP::cookie hectorlbhkg])
} else {
set PoolID [expr { int(rand()*[array size static::pools])}]
while { [info exists static::pools($PoolID)] } {
log local0. $PoolID
if { ([active_members $static::pools($PoolID)] >= 3) } {
pool $static::pools($PoolID)
set selected $static::pools($PoolID)
break
} else {incr PoolID}
}
}
}
when HTTP_RESPONSE {
if {[info exists selected]}{
HTTP::cookie insert name hectorlbhkg value $selected path "/"
}
}
The random value is an integer between 0 and the size of the static array. Adding a new entry in the array will apply without any change in the irule.
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