nik_65678
Oct 30, 2009Nimbostratus
irule-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 pools. we use very few vips for many sites and an irule will send traffic to the appropriate pool. the issue comes into play when i want to add the downtime page. currently i'm doing something like this:
switch [string tolower [HTTP::host]] {
"www.host.com" {
if { [active_members www.host.com_80] > 0 } { use pool www.host.com_80 }
else { use pool downtime_pool_80 }
}
"www.host.com" {
if { [active_members www.host3.com_80] > 0 } { use pool www.host3.com_80 }
else { use pool downtime_pool_80 }
}
"www.host.com" {
if { [active_members www.host3.com_80] > 0 } { use pool www.host3.com_80 }
else { use pool downtime_pool_80 }
}
}
so in my irule i have a whole bunch of these, all identical. now, i have a rule that looks something like this to return a maintenance/down page:
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.jpg" { HTTP::respond 200 content [b64decode [class element -value 2 maint_fxcm]] "Content-Type" "image/jpeg" }
default { HTTP::redirect "/" }
}
previously i would use the downtime_pool to send customers when we took nodes down for maintenance, it was automatic and worked fine. the issue i've run into is what happens when the server that hosts downtime_pool is broken? then there's no maintenance page.
does anyone have an idea how to replace the "use pool downtime" with "generate a page on the LB" so i don't have to repeat it for every single host? my only idea is to do something like this but it seems kind of expensive (excuse the psudo code):
if { [host == "www.host1.com"] and [active_members host1.pool] > 0 } { use pool host1 }
elseif { [host == "www.host2.com"] and [active_members host2.pool] > 0 } { use pool host2}
else { generate maintenance page }
anyway, i'd appreciate any suggestions that you guys may have on how to improve my situation. the number of sites we host only increases and these rules are getting pretty big. thanks!