LTM Maintenance Page Lite
Problem this snippet solves: Use the LTM as a webserver as a lite version of a maintenance page. In this case, it returns a maintenance page with text to return when the pool members are not availab...
Published Mar 18, 2015
Version 1.0CodeCentral_194
Cirrus
Joined May 05, 2019
CodeCentral_194
Cirrus
Joined May 05, 2019
Stanislas_Piro2
Oct 26, 2016Cumulonimbus
Hi,
I understand why there are some issues with this code... the code is not generic, it use some useless static configuration : pool name, http protocol...
Redirect must never include host and protocol if the target service is the same as current.
I changed the redirect and refresh URL to relative URL. the pool name is the one assigned to the tcp connection. I also change the refresh URL to previous URI and not /. this allow user to follow browsing and not go back to home page.
when RULE_INIT {
sets the timer to return client to host URL
set static::stime 10
}
when CLIENT_ACCEPTED {
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
Check if the URI is /maintenance
switch [HTTP::uri] {
"/maintenance" {
Send an HTTP 200 response with a Javascript meta-refresh pointing to the host using a refresh time
HTTP::respond 200 content \
"Maintenance page\
Sorry! This site is down for maintenance." "Content-Type" "text/html"
return
}
}
If the default pool is down, redirect to the maintenance page
if { [active_members $default_pool] < 1 } {
HTTP::redirect "/maintenance"
return
}
}