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
- JRahm
Admin
At its most basic:when RULE_INIT { set sorry "All Servers Down" } when HTTP_REQUEST { if {[active_members myPool] == 0} { HTTP::respond 200 content $::sorry } }
- hoolio
Cirrostratus
Sounds like a good feature request. To make it officially, you could open a case with F5 support. - dennypayne
Employee
You can accomplish the same thing as a backup pool by using priority within the pool. Just set the primary members (let's say there are three) with a higher priority than the backup nodes. Then set Minimum Active Members to 1, and if all 3 of the first priority group fail, the LTM will begin to use the backup node(s). - Geoff_31301
Nimbostratus
Hoolio,All Servers Down
- hoolio
Cirrostratus
- JRahm
Admin
Actually, I don't even use the RULE_INIT event. The entire response is an image:class sorrypage { type string filename "/var/class/unavailable.class" } rule sorrypage-rule { when HTTP_REQUEST { if {[active_members http-pool] == 0} { HTTP::respond 200 content [b64decode [lindex $::sorrypage 0]] "Content-Type" "image/png" } } }
- Geoff_31301
Nimbostratus
It's starting to - however the /error directory (and the if statement for the error_condition) is now confusing me - where does that /error supposed to exist?when RULE_INIT { set ::polr_html {All Servers Down} } when HTTP_REQUEST { if {[active_members myPool] == 0} if {$error_condition==1} { The error condition was true, so respond back to client from the iRule switch [string tolower [HTTP::path]] { /error/image.png { HTTP::respond 200 content [b64decode [lindex $::logo_png_class 0]] "Content-Type" "image/png"} default { HTTP::respond 200 content $::polr_html } } }
- hoolio
Cirrostratus
That's close. The /error/image.png only exists in the HTML you're sending to the client from the iRule. Can you give this a try?when RULE_INIT { set ::polr_html {All Servers Down} } when HTTP_REQUEST { log local0. "Received request from [IP::client_addr] to [HTTP::host][HTTP::uri], with [active_members myPool]" Check if the pool has any active members if {[active_members myPool] == 0}{ log local0. "No active members" The error condition was true, so respond back to client from the iRule switch [string tolower [HTTP::path]] { /error/image.png { log local0. "Request was for /error/image.png" HTTP::respond 200 content [b64decode [lindex $::logo_png_class 0]] "Content-Type" "image/png" } default { log local0. "Request was not for the image, so we're sending the HTML" HTTP::respond 200 content $::polr_html } } } }
- Geoff_31301
Nimbostratus
This works great! Thanks for all your help! - Geoff_31301
Nimbostratus
One more question... can you run multiple iRules that reference "when HTTP_REQUEST" on the same Virtual Server or would you have to combine them into one iRule? I will need to have an iRule like the following example on the same VS:when HTTP_REQUEST { if {[HTTP::cookie exists "cookieName"]} { HTTP::cookie decrypt "cookieName" "passphrase" } } when HTTP_RESPONSE { if {[HTTP::cookie exists "cookieName"]} { HTTP::cookie encrypt "cookieName" "passphrase" } }
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