Lazaro_Pereira_
Nov 11, 2014Nimbostratus
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!