Forum Discussion
MK_62657
Nimbostratus
Feb 13, 2008Using F5 as a fall back host
Hello:
Is any using the F5 device itself as a fall back host? I would like to host the maintenance page on the device itself if possible instead of having another server as the fallback host?
Thanks
MK
23 Replies
Sort By
- Colin_Walker_12Historic F5 AccountYes, you can absolutely have multiple iRules reference a single event on one virtual server.
- Geoff_31301
Nimbostratus
SO this logic should work - based on the trimmed down version without the image (for easier following):when RULE_INIT { set polr "We are currently performing maintenance. Please check back later." } when HTTP_REQUEST { if {[active_members Wildcard_Pool_Test] == 0} { HTTP::respond 200 content $::polr } elseif {[HTTP::cookie exists "cookieName"]} { HTTP::cookie decrypt "cookieName" "passphrase" } } when HTTP_RESPONSE { if {[HTTP::cookie exists "cookieName"]} { HTTP::cookie encrypt "cookieName" "passphrase" } }
- Geoff_31301
Nimbostratus
Excellent thanks, so I should just keep the cookie handling as a separate iRule...and put it behind the rule I have for checking if there aren't any nodes available? - hoolio
Cirrostratus
The version you have listed should work fine. As there isn't any conflict between the two rules, you could also add them separately on the same VIP without any issues. The HTTP_RESPONSE event won't trigger if you're sending a response using HTTP::respond. And I don't think there is any issue with trying to decode the cookie even if you're sending a redirect. It's basically up to you as to which is easier to manage. - Heiko_Engemann_
Nimbostratus
Hello. - hoolio
Cirrostratus
You can set the Location variable ::maint_prefix in the RULE_INIT event. I'm guessing the error you're seeing when trying to save the rule is because the example in the Codeshare post is exactly as it would appear in the bigip.conf. To save via the GUI, remove the rule definition "rule webserver {" and the last closing curly brace "}". - Heiko_Engemann_
Nimbostratus
Hello, - hoolio
Cirrostratus
If you're using the GUI or iRuler, here is the rule text you can paste in:when RULE_INIT { maint_prefix must not contain a trailing slash maint_prefix also must not exist on your real web servers set maint_prefix "/maintenancepage" set maint_len [string length $maint_prefix] } when HTTP_REQUEST { Service requests for files (URIs) from the maintenance page Note that we always service these pages, even if the http_pool is up set uri [HTTP::uri] if { $uri equals ${::maint_prefix} } { HTTP::respond 301 "Location" "${::maint_prefix}/" return } if { $uri starts_with "${::maint_prefix}/" } { trim off the maintenance prefix set uri [string range $uri $::maint_len end] Return the requested page switch $uri { "/" - "/index.html" { HTTP::respond 200 content [lindex $::maint_index_html 0] "Content-Type" "text/html" } "/logo.png" { HTTP::respond 200 content [b64decode [lindex $::maint_logo_png 0]] "Content-Type" "image/png" } default { HTTP::respond 404 } } return } If the http_pool is down, redirect to the maintenance page if { [active_members http_pool] < 1 } { HTTP::redirect "${::maint_prefix}/index.html" return } }
- hoolio
Cirrostratus
That worked as listed in the Codeshare example on 9.4.4. Are you defining the external class as a type 'string'? Can you try manually editing the class file on the filesystem and escape the backslashes as listed below:class maint.index.html.class { type string filename "/var/class/maint.index.html.class" }
"Maintenance pageSorry! This site is down for maintenance.",
- Heiko_Engemann_
Nimbostratus
in the conf is looks like this:All Servers Down
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