Forum Discussion
Stanislas_Piro2
Aug 22, 2017Cumulonimbus
Hi,
use table with virtual server name as key instead of global variables
when RULE_INIT {
set static::table_timeout 43200
}
when CLIENT_ACCEPTED {
if { [active_members [LB::server pool]] < 1 } {
set lb 0
} elseif { [active_members [LB::server pool]] > 0 } {
set lb 1
if {[table lookup -subtable maintenance [virtual name]] ne 1} {
table set -subtable maintenance [virtual name] 1 $static::table_timeout 0
}
}
}
when HTTP_REQUEST {
if {$lb ==0}{
switch -glob [HTTP::path] {
"*/image1.png" {
HTTP::respond 200 content [ifile get imagefile1] "Content-Type" "image/png"
}
"*/image2.png" {
HTTP::respond 200 content [ifile get imagefile2] "Content-Type" "image/png"
}
default {
if {[expr {[table lifetime -subtable maintenance -remaining [virtual name]] - $static::table_timeout}] < 300}{
HTTP::respond 200 content [ifile get Sorry_Page] "Content-Type" "text/html" noserver
}
else {
HTTP::respond 200 content [ifile get Sorry_Page_5] "Content-Type" "text/html" noserver
}
}
}
}
TCP::close
}