Forum Discussion
Gill_32697
Nimbostratus
Feb 06, 2013irule for default and backup secondary pool
Need help fixing the second half of this irule, after the redirect.
I will be adding a new pool as a backup pool incase the default pool members al all down. So is defaul HQ-Pool is down then us...
Kevin_Stewart
Employee
Feb 06, 2013You 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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects