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
- Colin_Walker_12Historic F5 AccountYes, you can absolutely have multiple iRules reference a single event on one virtual server.
Colin - 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.
Aaron - Heiko_Engemann_
Nimbostratus
Hello.
thx for the answer, i thought someting like that.
I still get an error when I try to insert the irule,
do i hav eto set the location in "HTTP::respond 301 "Location" "${::maint_prefix}/""
to the pool? - 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 "}".
If you still get an error, can you reply with the error text?
Aaron - Heiko_Engemann_
Nimbostratus
Hello,
but when I remove the whole webserver section, there is nothing left than the 2 class definition,
maybe I miss something here.
This is the error I get
01070151:3: Rule [offline_sites_redirect_2] error:
line 1: [undefined procedure: class] [class maint_index_html {
type string
filename "/var/class/maint.index.html.class"
... - 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 } }
The classes are defined separately in the GUI under Local Traffic >> iRules >> Datagroup List.
Aaron - 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" }
cat /var/class/main.index.html.class"Maintenance pageSorry! This site is down for maintenance.",
And no, if you're redirecting the client the address bar will be updated with the new location. You can pick whatever URL by modifying the redirect location, but you can't hide the change with this type of implementation.
Aaron - Heiko_Engemann_
Nimbostratus
in the conf is looks like this:
class maint_logo_png extern {
type string
filename "/var/class/maint.logo.png.class"
}
class maint_index_html extern {
type string
filename "/var/class/maint.index.html.class"
}
I liked the irule at the beginning of this thread,
when RULE_INIT {
set sorry "All Servers Down
"
}
when HTTP_REQUEST {
if {[active_members myPool] == 0} {
HTTP::respond 200 content $::sorry
}
}
it did keep the original URL, so the visitor only sees the domain and no internal stuff.
Cant we insert a picture there?
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
