Forum Discussion
nik_65678
Nimbostratus
Oct 30, 2009irule-based redirection & maintenance page
i'm trying to figure out a good irule-based solution for an irule-based downtime/maintence page. i already have the code for my downtime page done, however i'm wondering how to implement it on many p...
nik_65678
Nimbostratus
Nov 02, 2009i worked on this a bit this morning and came up with the following to fit my needs:
when HTTP_REQUEST {
make sure $dn is an actual pool
set dn "empty_pool"
choose a vhost based on requested site name
switch [string tolower [HTTP::host]] {
www.sitename1.com { set up www.sitename.com; set dn www.sitename.com_down }
www.sitename2.com { set up www.sitename.com_80 }
www.complexsite.com { set up www.complexsite.com }
}
check for sites that need special treatment first, then sites that are up
then down sites (with a down pool), then down sites (with no down pool)
if { $up equals "www.complexsite.com" and [active_members $up] > 0 } {
switch -glob [string tolower [HTTP::uri]] {
"/uri1*" - "/uri2*" - "/uri3/pagename.html" { use pool $up }
default { HTTP::uri "/append/to/beginning[HTTP::uri]"; use pool $up }
}
}
elseif { [active_members $up] > 0 } { use pool $up }
elseif { [active_members $dn] > 0 } { use pool $dn }
else {
switch -glob [string tolower [HTTP::uri]] {
"/" { HTTP::respond 200 content [b64decode [class element -value 0 maint_fxcm]] "Content-Type" "text/html" }
"/logo.gif" { HTTP::respond 200 content [b64decode [class element -value 1 maint_fxcm]] "Content-Type" "image/gif" }
"/top-backbanner.jpg" { HTTP::respond 200 content [b64decode [class element -value 2 maint_fxcm]] "Content-Type" "image/jpeg" }
default { HTTP::redirect "/" }
}
}
}
thanks again for the suggestions.
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
