Forum Discussion
iRule for maintenance page
I want to write an irule for maintenance page such that the single iRule can be applied to multiple VS. Presently we are using the below irule
when HTTP_REQUEST {
if {[active_members pool A] < 1}{
HTTP::redirect } }
Problem here is we have to change the pool name when applying irule to different VS.
Is there any command in irule to get the default pool of the vs.
Thanks in advance.
Regards,
Sid
- Chris_MillerAltostratusYou can use "LB::server pool" from the CLIENT_ACCEPTED event.
when CLIENT_ACCEPTED { set dpool [LB::server pool] } when HTTP_REQUEST { if { [active_members pool $dpool] < 1 } { HTTP::redirect "http://maintenancepage.html" } }
- Colin_Walker_12Historic F5 AccountNice one Chris. Very simple yet quite handy. You could even set up a class that stores individual maintenance URLs for each possible end pool and still use a single iRule across all your Virtuals to deploy pool specific maintenance pages.
- Siddarth_84779Nimbostratuswow!! exactly what i wanted.
- Kevin_StewartEmployee
You could technically evaluate the default pool directly in the HTTP_REQUEST event:
if { [active_members [LB::server pool]] < 1 } { [do something] }
But you'll likely find the difference in memory footprint negligible.
- JGCumulonimbus
I need an inline (no HTTP redirect) long maintenance page for a particular website, and I want to get around the bug in "LB_FAILED" (ID 222034). Below is a cut-down version of my code:
when HTTP_REQUEST { switch -- [string tolower [HTTP::host]] { "www.example.com" { pool www.example.com_pool set selected_server [LB::server addr] if {$selected_server == ""} { If there are no members available, generate a long Maintenance Page HTTP::respond ... } } "www.example2.com" { pool www.example2.com_pool ... } } }
Will anybody comment on whether this will work, or if there is anything not right here, or if there is a better way to achieve the same effect?
- DenisG_22372Historic F5 Account
I think a better way would be to do a check if there are pool members before you select the pool. I would look at the example:
when HTTP_REQUEST { switch -- [string tolower [HTTP::host]] { "www.example.com" { if { [active_members www.example2.com_pool] < 1 } { If there are no members available, generate a long Maintenance Page HTTP::respond ... } else { pool www.example.com_pool } "www.example2.com" { pool www.example2.com_pool ... } }
}
Hopefully this will get you started to getting this working
- JGCumulonimbusThis is certainly better! I cut-and-pasted the code from two of my other servers each of which had very different requirements and different strategies. In one I did not have a default pool configured, and in the other I did not want to specify the name of the pool. I should not consider either here. Thanks!
- r_dynamoNimbostratus
How do I create an iRule on the GTM that redirects to a maintenance page, if all Virtual Servers in a pool are not available?
- Kevin_StewartEmployee
Understand of course that GTM does DNS, and you're looking for an HTTP redirect. Two different things. You can certainly create an LTM iRule to redirect to a maintenance page if pool members are down. But a DNS request isn't going to produce an HTTP response.
- r_dynamoNimbostratus
Thanks Kevin for your response. How about a maintenance page in case both virtual servers are available in a Wide IP pool? This particular application has to be in an active standby state. If one of the virtual servers are not available I can setup the maintenance page at the LTM level. I also want a maintenance page in case both virtual servers are available in a WIP pool.
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