You wouldn't want to use that redirect code on your production virtual server. It would cause an infinite redirect loop. Instead put it on an empty port 80 virtual with the same IP address.
Here's another version of code that might also work for you (on the production virtual):
when RULE_INIT {
set static::BACKUP_POOL "local1-pool"
}
when HTTP_REQUEST {
set default_pool [LB::server pool]
log local0. "in event: $default_pool"
if { [active_members $default_pool] < 1 } {
log local0. "no members in default pool"
if { [active_members $static::BACKUP_POOL] < 1 } {
log local0. "no members in backup pool"
HTTP::respond 200 content "No pool members available"
} else {
pool $static::BACKUP_POOL
}
}
}
Remember to remove or comment out the log statements and set the name of the backup pool in RULE_INIT. Because the pool status check is happening in HTTP_REQUEST, you can send the user a message if the backup pool is also down. If you remove the HTTP::respond line you can use this same code in a CLIENT_ACCEPTED event.