BIGIP F5 iRule — Return Splash Page When No Members Are Available

I wrote a iRule post located here, where I describe the essentials behind how beneficial iRules can be and the many use cases they have. I stumbled across a situation the other day for a client. This client had an F5 VIP load balancing 2 web servers of theirs. Now if those web servers for some reason are not available due to their healthcheck monitor failing, the users of that web site will receive a white page as the F5 will not proxy the traffic because there are no available pool members. I thought what if this was a big site, should users be left in the dark about a web site they use frequently when it’s not available? Then the idea of having the F5 LTM bounce back a well-formed splash page. This splash page would inform the user that the web site temporarily down, and if they believe this result is in error to contact their helpdesk.

This situation can be remedied with a couple of lines in an iRule.

when HTTP_REQUEST {
    #check if no members available
    if { [active_members [LB::server pool]] == 0 } {
       #create data variables with HTML content to send to client
       set httphost [string tolower [HTTP::host]]
       set data "

$httphost

NOTICE: Site Unavailable.

If you believe you are receiving this message in error, contact your site administrator.

" #send string HTTP::respond 200 content $data } #unset variables unset $httphost unset $data }

 

Or:

when HTTP_REQUEST {
   #check if no members available
   if { [active_members [LB::server pool]] == 0 } {
      HTTP::respond 200 content {
      
      Unavailable
      
      

If you believe you are receiving this message in error, contact your site administrator.

} #end of content block }

 
This iRule uses the when HTTP_REQUEST event, and the HTTP::respond function. You could also use the HTTP::redirect function, however for something as small as a few lines, might as well have the F5 handle it directly.

You could easily use links from other sources to make a more authentic looking page for your users.

There are 2 comments left Go To Comment

  1. Jesse /

    JimMan,

    Can you give me a example of a irule where I use a different link that goes to a customized downpage. Curious where that would go and look like

    1. thejimmahknows / Post Author

      You could redirect the user with a HTTP 302, or something similar based on the pool member availability being less then 1.

Leave a Reply

↓