HTTP Redirect When Pool is down

I would like to craft an iRule that detects the pool assigned to the VIP has all members down. When it is down then do an http redirect to our site down web server. I have rules in place where I call a specific pool in the rule, but I would like to make it more generic so that I can apply it to any VIP without having a rule for every VIP. I posted an example of what we have been doing up to this point. Thanks.

when HTTP_REQUEST { if { [active_members RSAGA-Juniper-Pool-Prod] < 1 or [active_members RSAGA-Juniper-Radius-Pool-Prod] < 1 } { HTTP::redirect “http://frdcsd.app.medcity.net/vdi/” }

}

is LB::server pool usable?

LB::server

e.g.

when HTTP_REQUEST { 
  if { [active_members [LB::server pool]] < 1 } {
    HTTP::redirect "http://frdcsd.app.medcity.net/vdi/"
  }
}

Thanks. I was reading the “pool” as where I was to put the name not just a generic default pool reference.

thats nice. Till today, I did it on the same way like Joe.

Additional question:

If I put this in a seperate irule and respond with a HTTP::respond instead of an HTTP::redirect, do I need to add a priority tag to the HTTP_request and and an event deisable behind?

i.e.:

  • one global irule for availability check

    when HTTP_REQUEST priority 999 {
        if { [active_members [LB::server pool]] < 1 } {  
            HTTP::respond 503 "Server is down"
    
            event disable all
            return
        }  
    }
    
  • custom irule for VS

    when HTTP_REQUEST {do some stuff}
    

If I put this in a seperate irule and respond with a HTTP::respond instead of an HTTP::redirect, do I need to add a priority tag to the HTTP_request and and an event disable behind?

i would do to ensure there is no conflict (e.g. multiple redirects). please be noted that event will be disabled throughout the connection or until event is re-enabled.

If I put this in a seperate irule and respond with a HTTP::respond instead of an HTTP::redirect, do I need to add a priority tag to the HTTP_request and and an event disable behind?

i would do to ensure there is no conflict (e.g. multiple redirects). please be noted that event will be disabled throughout the connection or until event is re-enabled.

ok, I will test it. Perhaps, an “event enable all” outside the if condition would be a good add

ok, I will test it. Perhaps, an “event enable all” outside the if condition would be a good add

Wouldn’t it be simpler to make use of LB_FAILED for this?

when LB_FAILED {
        HTTP::respond 503 content "server is down"
        return
}

it looks simpler, but it isn’t 1. it is triggered after http_request, but I want to check the pool before I do all the irule stuff

2. it is a result of different problems (or failures). Checking for active members is a result of the healthcheck only.

The advantages of using LB_FAILED are that;

  • it catches when the pool is down (no active members) and also when the pool has not been marked down, but the pool member chosen is unresponsive, so it’s actually more powerful than just checking [active_members [LB::server pool]]
  • it’s slightly more efficient as it saves potentially unnecessary checking in HTTP_REQUEST and you wouldn’t need to worry about event disabling in HTTP_REQUEST (assuming you do not implement LB_FAILED in your other iRules) - this may not be a concern but worth noting

There may be other situation-specific reasons for wanting to execute the check in HTTP_REQUEST but if not LB_FAILED works well too as a generic rule for catching errors.

Beware of this, though:

sol9456: Using the HTTP::respond iRule command in the LB_FAILED event may result in truncated responses

Long-standing issue that does not seem to have been resolved.

If doing a 302 redirect to a sorry page though as the original asker wanted, this would not be a problem.

Having said that…I think you’ve just directed me to a solution I needed!! I have seen this behaviour when trying to return large pages with embedded content to the client and was meaning to raise a case (but now don’t need to).

there are many ways to rome :wink:

if you do a lot of irule stuff, I would say, it is more efficient to check for a reachable backend before. So you can save some resources on f5. Especially, if you running ASM, too.

So, the request will be blocked at the beginning and will not run through a security policy before it get an redirect. But Im not 100% shure, if the security policies comes before LB_FAILED. I didn’t find a picture over all the events, only this nice one:

event order

But I agree, LB_Failed is much more powerful than a simple pool member check.

I am actually trying the LB_FAILED. It gives me a generic rule I can deploy on a high number of VIPS, and it also allows for a more efficient iRule.