Forum Discussion

lucaspawpaw_559's avatar
lucaspawpaw_559
Icon for Nimbostratus rankNimbostratus
Jul 29, 2011

Balance to webserver port based on value held in status file

Hi all,

 

 

 

First time poster, and recently getting into load balancing. I'm perfectly fine with setting up virtual servers to do the basic tasks, but I'm getting stuck on iRules. Is the below possible with an iRule?

 

 

 

The client wants to have a status text file, which would have 3 numbers in it. 1, 2 or 3. Based on the value in the text file I want the F5 to follow a certain set of rules, below is the flow how I imagine it:

 

 

 

 

 

value=1 send https: traffic to port 7007 (Release N)

 

if Release N is unreachable then send the traffic to port 7008 (Release N+1)

 

if Release N and Release N+1 are unreachable, then display the generic outage page from the F5 ("We apologise, the website you are trying to reach is current experiencing technical difficulties.")

 

 

value=2 send https: traffic to port 7008 (Release N+1)

 

if Release N+1 is unreachable then send the traffic to port 7007 (Release N)

 

if Release N and Release N+1 are unreachable, then display the generic outage page from the F5 ("We apologise, the website you are trying to reach is current experiencing technical difficulties.")

 

 

value=3 send https: traffic to a page static page on the IIS server (eg, http://server/schedoutage.html which says 'We apologise, the we are currently down for maintenance, the expected restoration is 8pm)

 

 

 

If the status text file on the server is 404, then display the generic outage page from the F5 ("We apologise, the website you are trying to reach is current experiencing technical difficulties.")

 

 

 

Is this possible on the F5? And if so, could someone please give me some pointers? I really would appreciate it :)

 

 

 

Thankyou all so much, and once I get up to speed with iRules, I look forward to helping the community out too.

 

 

 

  • how many servers are supposed to be behind this VIP?

     

    If multiple servers, what is the expected behavior if one server returns a 1, another a 2, another a 3, and the last a 404?
  • Hi lucaspawpaw,

     

    iRule cannot directly read the value of a text file. However, you can read a value for your sorry page indirectly.

     

     

     

    For example (let's assume you have 3 values)

     

    1. You can create a ping page http://www.domain.com/ping.html. Contained in the ping.html page will hold a value.

     

    2. You then create 3 F5 monitors associated to 3 new "dummy" pools. These pools will contain node members that will host the ping.html file

     

    3. You then create an iRule similar to the one below

     

     

    when CLIENT_ACCEPTED {

     

    if { [active_members pool1] = 0 } {

     

    pool pool7007

     

    return

     

    } else if {[active_member pool2] = 0 {

     

    HTTP::respond 404 content "SORRY PAGEWe apologies, the website you are trying to reach is current experiencing technical difficulties"

     

    return

     

    }

     

    }

     

     

    The way it works is that monitor fails then the irule will catch the failure as a 0 available members in a specific pool which would then be triggered to "Do something" based on those condition

     

     

    I hope this helps

     

    Bhattman