Forum Discussion
Waynew_97737
Nimbostratus
Mar 11, 2009How to do http redirect
We are presently in the process of migrating all stuff from CSS's to F5s. Presently, we have a CSS with a configuration that does something like this
User goes to https://www.acme.com ...
hoolio
Cirrostratus
Mar 11, 2009Do you really want to send the client a redirect? This will update the address bar in the browser and potentially prevent LTM from load balancing the requests if acme1.com and acme2.com don't resolve to a VIP address.
If so, here is a rough example of this ratio load balancing. I'm sure there are other ways to do it, but this is one method.
Aaron
when RULE_INIT {
Log debug messages (to /var/log/ltm)? 0 = no, 1 = yes.
set ::site_router_debug 0
Percentage of new requests to send to new site (valid values: integers from 0 - 10; with 1 being 10%, 5 being 50%, 10 being 100%)
set ::site1_ratio {5}
Initialise a counter for ratio load balancing between the legacy and new site.
(this value shouldn't be changed)
set ::counter 0
}
when HTTP_REQUEST {
Send first X out of 10 requests to the new site. Then send next 10 minus X requests to the legacy site.
if {$::counter < $::site1_ratio}{
if {$::site_router_debug}{log local0. "Counter < max: $::counter < $::site1_ratio. Selected site1."}
Redirect to a URL. Set headers to prevent caching of response.
HTTP::respond 302 \
"Location" "https://site1" \
"Connection" "Close" \
"Cache-Control" "no-cache" \
"Pragma" "no-cache"
} else {
if {$::site_router_debug}{log local0. "Counter > max: $::counter > $::site1_ratio. Selected site2."}
Redirect to a URL. Set headers to prevent caching of response.
HTTP::respond 302 \
"Location" "https://site2" \
"Connection" "Close" \
"Cache-Control" "no-cache" \
"Pragma" "no-cache"
}
Increment the counter for ratio load balancing
incr ::counter
If counter is over the max, reset it to 0
if {$::counter > 10}{
set ::counter 0
if {$::site_router_debug}{log local0. "Counter: $::counter, resetting to 0"}
}
}
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
