Forum Discussion

sande06_81266's avatar
sande06_81266
Icon for Nimbostratus rankNimbostratus
Oct 24, 2013

IRule for sending traffic to another server if the first server is down or second server is down

Does anyone have any input on how I can send traffic via an iRule if the following scenario occurs? Server A is offline, send all traffic to pool member Server B. If Server A and B are down, send all traffic to pool member C.

 

Thanks

 

6 Replies

  • Priority group.

    In the pool, set Priority Group Activation to "less than 1", then give each pool member a priority number. The higher the number the greater the priority. Example:

    ServerA - priority 3
    ServerB - priority 2
    ServerC - priority 1
    

    With Priority Group Activation, all traffic will be sent to priority number 3 servers until they all fail, then priority number 2 servers, and then priority number 1. Also makes sure you have a good monitor applied to the pool. No iRule required.

  • I probably should have mentioned that the 3rd server or server C would be a vip that exists on the f5 load balancer. So really it should read: If server A is offline, send all traffic to server B. If server A and B are down, then send all traffic to an existing vip on the f5 load balancer.
  • Will this cause an issue within the f5 if we are sending the traffic back to an existing vip?
  • Do you mean that you want to send traffic to another VIP behind the first VIP, or simply redirect to the third VIP is servers A and B are offline?
  • Yes, it would be like a redirect traffic to this vip if server A and B are down.
  • Yes, it would be like a redirect traffic to this vip if server A and B are down.

    Okay, so same priority group settings for servers A and B, and the following iRule:

    when CLIENT_ACCEPTED {
        set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
        if { [active_members $default_pool] < 1 } {
            HTTP::redirect "http://foo.example.com"
        }
    }
    

    All traffic will go to server A until it fails, then to server B until it fails. If servers A and B fail, the client will be issued an HTTP redirect to the URL of choice.