Forum Discussion

Jim_Mathers_131's avatar
Jim_Mathers_131
Icon for Nimbostratus rankNimbostratus
Apr 18, 2017

Check for persistence entry before invoking HTTP::respond 200 content

Hello,

I've the following simple iRule that sends a Sorry Server message when no Pool Members are active:

when HTTP_REQUEST {
    if { [active_members [LB::server pool]] == 0 } {
        HTTP::respond 200 content "The application is currently unavailable"
    }
}

However, I've noticed that { [active_members [LB::server pool]] == 0 } if the Pool Members are down or Disabled (there is Recv Disable String in the HTTP monitor so the app team can signal to drain connections). So, when the servers are in disabled state, { [active_members [LB::server pool]] == 0 } so the Sorry content is returned and this is undesirable. Instead, I'd like the iRule to check for a persistence entry for the client (using cookie persistence) and if one exists allow them to connect to the Pool Member. If a persistence entry doesn't exist, then I'd like them to get "The application is currently unavailable".

How do I do this?

Thanks, Jim

  • You can use [HTTP::cookie exists ] to see if a persistence cookie was passed from the client to BIG-IP. By default, the name of the cookie is "BIGipServer" - so if your pool is named "http_pool" the cookie name is "BIGipServerhttp_pool" (You'll need to check your cookie persistence profile to see if the persistence cookie is named something other than the default.)

    For example:

    when HTTP_REQUEST {
        if { ![HTTP::cookie exists "BIGipServerhttp_pool"] } {
            if { [active_members [LB::server http_pool]] == 0 } {
                HTTP::respond 200 content "The application is currently unavailable"
            }
        }
    }
    
  • I think this simple snippet will work for you:

    when LB_FAILED {
            HTTP::respond 200 content "The application is currently unavailable"
    }