Really confused here. If customers were asking for direct traffic to different pool, things will be lot easier for me. Do not know how to direct the traffic to three URI with round robin, please help. Thanks
when RULE_INIT {
Initialize a global counter
set ::redirect_counter 1
}
when HTTP_REQUEST {
Check if URI is /test.html
if {[HTTP::uri] eq "/test.html"}{
Redirect client according to the counter value
HTTP::redirect "http://[HTTP::host]/test${::redirect_counter}"
Increment the counter
incr ::redirect_counter
Reset the counter if it's over the limit
if {$::redirect_counter > 3}{
set ::redirect_counter 1
}
}
}
If the URI’s don’t literally ending with a number, you could use something like this:
when RULE_INIT {
Initialize a global counter
set ::redirect_counter 1
}
when HTTP_REQUEST {
Check if URI is /test.html
if {[HTTP::uri] eq "/test.html"}{
Redirect client according to the counter value
switch $::redirect_counter {
1 {
HTTP::redirect "http://[HTTP::host]/testUrlOne"
}
2 {
HTTP::redirect "http://[HTTP::host]/testUrlTwo"
}
3 {
HTTP::redirect "http://[HTTP::host]/testUrlThree"
}
}
Increment the counter
incr ::redirect_counter
Reset the counter if it's over the limit
if {$::redirect_counter > 3}{
set ::redirect_counter 1
}
}
}