Forum Discussion
Martin_Kaiser_1
Nimbostratus
Oct 20, 2005Dynamic redirect to fallback host
Hi Everybody,
I'm new to BigIP V9 and iRules, so I need your assistance with writing an iRule for a BigIP Loadbalancer that balances several webserver pools.
I have to build a rule that allows redirection of incoming http requests to a maintenance page in case a certain pool is not available. Because the redirection must be dynamic (dependent on the requested URI), we cannot use the standard fallback host function. There is already an iRule that is bound to the virtual server. This one checks for the requested URI and chooses the appropriate pool of webservers.
The rule looks like that:
---BEGIN---
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/abc/" } {
pool pool1
}
elseif { [HTTP::uri] starts_with "/def/" } {
pool pool2
}
else {
pool default_pool
}
}
---END---
This is so far the only rule that is bound to the VIP.
I thought about adding a statement like that:
---BEGIN---
when LB_FAILED {
if { [HTTP::uri] contains "/abc/" } {
HTTP::redirect https://some.maintenancesite.com/abc
}
elseif { [HTTP::uri] contains "/def/" } {
HTTP::redirect https://some.maintenancesite.com/def
}
else {
HTTP::redirect https://some.maintenancesite.com/
}
}
---END---
Will this work if it is appended to the end of the original rule or will I have to build another rule and bind it to the same VS as second one?
Or maybe, is there any other way to achieve the wanted result?
Any help is greatly appreciated!
Thanks in advance!
Regards,
Martin
4 Replies
- Colin_Walker_12Historic F5 AccountYou should be able to tac that code to the end of the existing rule without a problem.
- Martin_Kaiser_1
Nimbostratus
Thanks!when LB_FAILED pool1 { HTTP::redirect http://some.maintenancesite.com/
- drteeth_127330Historic F5 AccountNo, you'll have to query it.
- unRuleY_95363Historic F5 AccountYou'll want to look at the LB::server command. It will return information about the load-balancing decision (eg: the pool and member of the pick). You can specifically get just the pool with: [LB::server pool].
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