Forum Discussion
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
Nimbostratus
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 $dataThis should check for active members in the current selected pool and remove the need to check each individual pool in each switch entry
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com