Forum Discussion

Lazaro_Pereira_'s avatar
Lazaro_Pereira_
Icon for Nimbostratus rankNimbostratus
Nov 11, 2014

Content Switch with Sorry Page

Hi Everyone,

 

I am using content switching to use HTTP host to decide what pool traffic should go to. I would also like to be able to display a "Sorry" Error page if all the servers in a pool are down. I came up with the following:

 

when HTTP_REQUEST {
      switch [string tolower [HTTP::host]] {
        "server.company.com" {
              if { [active_members /Internal/F5-Internal-Pool_server1-pool] == 0 } {
              create data variables with HTML content to send to client
              set httphost [string tolower [HTTP::host]]
              set data " $httphost Sory: The Site you are trying to reach is currently Unavailable. If you believe you are receiving this message in error, contact our service desk at XXXXX."
              send string
              HTTP::respond 200 content $data 
             } 
          pool /Internal/F5-Internal-server1-pool
        }
        default {
          discard
        }
      }
    }

My only issue with this is that I have to use the active member check code for each entry in the switch. Is there a way to condense this down? I will use the same html for any server pool which might be down.

 

Thanks in advance!

 

1 Reply

  • shaggy's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    You could insert a check after the switch statement similar to:

    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 Sorry: The Site you are trying to reach is currently Unavailable. If you believe you are receiving this message in error, contact our service desk at XXXXX."
              send string
              HTTP::respond 200 content $data 
    

    This should check for active members in the current selected pool and remove the need to check each individual pool in each switch entry