Forum Discussion
Angus_2141
Jul 16, 2013Historic F5 Account
redirect based on monitor status
I would like to have a process where I am able to redirect a user to site down for maintenance page based on status of monitor. My workflow would be using a monitor to check for the content of a fil...
ag_g_2058
Nimbostratus
Jul 31, 2013Hi Kevin and Nitass,
First off thanks for your input. As it turns out I had not really stopped to consider the disable string functionality until Nitass pointed it out to me. That is basically what I am looking for but I had not realized it was available until today. Based on that knowledge I played around a little bit today until I got the following basic irule to work.
when HTTP_REQUEST {
if { [LB::status pool application-maintenance-pool member 192.168.2.1 443 ] eq "session_disabled" } {
log local0.info "Server marked disabled, maintenance page enabled"
HTTP::redirect "http://example.com/errors/maintenance.html"
}
}
This is great but as I was considering this sitaution again today I realized that historically my logic has been a bit confused regarding monitors and status changes. In the past I have been using simple file monitors that check for the contents of a file and if that check fails the respective node is pulled from pool. This was being used by administrators to pull hosts from their pools on demand. However, what I really wanted was the stop accepting new connections and let the existing connections complete their session and for this I shoud have been using the "recv disable" response.
So, with this new knowledge and much to Kevin's point I wonder if it is a good idea to splash a maintenance page based on the status of a single node in the pool. I think a better plan is to allow all nodes in the pool to return a "session_disabled" status. At at this point I would like to put up a site down for maintenance page for any new connections.
The other conditional here woud be that if alll nodes in a pool return a "down" status then I would like to put up a "sorry we are experiencing technical difficulties" page.
The problem I have now is how to confirm that all nodes in a pool are in a disabled status. The following code is close but I do not have a way to test the total response from a pool.
when HTTP_REQUEST {
if { [LB::status pool testapp-pool member 192.168.2.1 443 ] eq "session_disabled" } {
log local0.info "Server marked disabled, maintenance page enabled"
HTTP::redirect "http://example.com/errors/maintenance.html"
} elseif { [active_members [LB::server pool]] == 0 } {
HTTP::redirect "http://example.com/errors/sitedown.html"
log local0.info "no active enabled members in pool, site down enabled"
} elseif {[HTTP::uri] equals "/" } {
HTTP::redirect "https://[HTTP::host]/default/logon"
}
I tried to use something like [ LB::status ] eq "session_disabled" but this did not seem to evaluate the pool which I sort of expected as the status argument assumes the node has already been selected. But maybe that is how I should start my loop assuming that is an option.
Thanks.
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