I'd like to check node availability and redirect only if the node is up and skip that node and go on to the next if it's down.can you try something like this?
[root@ve10:Active] config b rule myrule list
rule myrule {
when RULE_INIT {
Round robin counter
set static::c 0
Round robin node
www1.url.com = 200.200.200.101
www2.url.com = 200.200.200.111
www3.url.com = 200.200.200.103
www4.url.com = 200.200.200.113
unset static::node
set static::node(0) "200.200.200.101"
set static::node(1) "200.200.200.111"
set static::node(2) "200.200.200.103"
set static::node(3) "200.200.200.113"
}
when HTTP_REQUEST {
Pick up round robin node
set try 0
while { [LB::status node $static::node($static::c)] ne "up" and $try < [array size static::node]} {
if { $static::c == [expr {[array size static::node] - 1}] } {
set static::c 0
} else {
incr static::c
}
incr try
}
Action when all nodes are down
if { $try == [array size static::node] } {
HTTP::respond 200 content "sorry we are not ready" noserver
return
}
Send HTTP redirection
switch $static::c {
0 { HTTP::redirect "http://www1.url.com" }
1 { HTTP::redirect "http://www2.url.com" }
2 { HTTP::redirect "http://www3.url.com" }
3 { HTTP::redirect "http://www4.url.com" }
}
Move to next round robin node
if { $static::c == [expr {[array size static::node] - 1}] } {
set static::c 0
} else {
incr static::c
}
}
}