Forum Discussion
iRule load balancing redirect with a pool
I'd like to make an iRule that works as load balancing redirect with a pool.
This pool works fine when the virtual server without any iRule. But this iRule gets error at line 4 { arra set ...}. This pool has 2 members working fine. Its status is green. The Standard tcp monitor is attached to this pool.
Please let me know how solve this. Thanks.
when HTTP_REQUEST {
incr ::Counter1
if{$::Counter1 > 30000}{set ::Counter1 0}
array set AML [active_members -list [LB::server pool] ]
set cc [active_members [LB::server pool] ]
if{$cc < 1}{
HTTP::respond 404 "All servers are not active."
}
set index [$::Counter1 % $cc]
HTTP::redirect "http://[$AML($index)::IP]"
}
6 Replies
- R_Eastman_13667Historic F5 Account
Try this:
set AML [active_members -list [LB::server pool]]- Kiyoshi_kobayas
Nimbostratus
I tested that way.But result was same. Thanks.
- shaggy
Nimbostratus
i'm intrigued by your LB-method logic - [$::Counter1 % $cc]
i have a similar iRule in which i use LB::select in HTTP_REQUEST to select a member from a pool and compose my redirect with that result:
if { [active_members [LB::server pool]] == 0 } { HTTP::respond 404 "No servers" noserver } else { set sel_mem [LB::select] HTTP::redirect "http://[getfield $sel_mem " " 4]:[getfield $sel_mem " " 5][HTTP::uri]"- Kiyoshi_kobayas
Nimbostratus
Thanks! This irule works fine.
- shaggy_121467
Cumulonimbus
i'm intrigued by your LB-method logic - [$::Counter1 % $cc]
i have a similar iRule in which i use LB::select in HTTP_REQUEST to select a member from a pool and compose my redirect with that result:
if { [active_members [LB::server pool]] == 0 } { HTTP::respond 404 "No servers" noserver } else { set sel_mem [LB::select] HTTP::redirect "http://[getfield $sel_mem " " 4]:[getfield $sel_mem " " 5][HTTP::uri]"- Kiyoshi_kobayas
Nimbostratus
Thanks! This irule works fine.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
