Multiple HTTP Redirect w/ load balancing and monitoring request

Problem this snippet solves:

The goal is to even distribute HTTP Request via redirect to clients requesting a web server (i.e. URL).

How to use this snippet:

Hi F5 Crew,

I am toying with a few HTTP::redirect and monitor combos. I need some help validating my creation. It works in my stand alone VM Workstation set up. However, I getting mix results with Code 11.2.1 and above on several dev labs. Also, I substituted the URL/URI with node addresses (i.e. 10.2.0.22, etc.) - no DNS set up, which works the same.

Code :

when HTTP_REQUEST {
     set rand [expr { rand() }]
     if { [active_members MY_POOL] > 1 } {
         set rand [expr { rand() }]
           if { $rand < 0.50 } {
           HTTP::redirect http://www.codeme.org[HTTP::uri]
      } elseif { $rand > 0.50 } {
            HTTP::redirect http://www.codeme2.org[HTTP::uri]
         }
}

Tested this on version:

12.1
Published Mar 15, 2017
Version 1.0
No CommentsBe the first to comment