Passing a variable through an iRule
We have the following maintenance test page, it's based off the standard maintenance page. What we are trying to do is create a dynamic maintenance page for each site(pool) so all we would have to do is just upload two ifiles and the irule wouldn't have to be adjusted. so lets say someones tries to go to www.abc.com, hits the F5, goes to the www.abc.com pool, however all of it's memebers are down. we have iFiles called www.abc.com.html and www.abc.com.jpg, the irule would find the files for www.abc.com and then display their own maintenance page. Later on we would add files for www.xyz.com and if www.xyz.com is down, their custom page would be displayed.
when CLIENT_ACCEPTED {
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
set htmlfile
set imagefile
if { [active_members $default_pool] < 1 }{
$htmlfile = lsearch -exact $default_pool.html
$imagefile = lsearch -exact $default_pool.jpg
log local0. $imagefile
if{!($htmlfile equals $default_pool)} {
if { [HTTP::uri] contains $imagefile } {
HTTP::respond 200 content [ifile get $imagefile] noserver "Cache-Control" no-cache "Server"
} else {
log local0. "[HTTP::host] for client [client_addr]"
HTTP::respond 200 content [ifile get $htmlfile] noserver "Cache-Control" no-cache "Server"
}
}
}
}
with the above I get the following message when I tail the LTM log
err tmm[8134]: 01220001:3: TCL error: /Common/Maint_test - can't read "htmlfile": no such variable while executing "set htmlfile"