Forum Discussion
nik_65678
Nov 02, 2009Nimbostratus
i 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.