Forum Discussion
scottl_82413
Nimbostratus
Feb 04, 2010Redirect via Round Robin
Hello,
I'm not sure if an iRule is the best way to do this, or if the LTM can handle it in a better way.
We're going to publish a single URL - www.url.com, but need to re...
nitass
Employee
Mar 23, 2013I'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
}
}
}
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