Forum Discussion
rwagner1
Aug 16, 2017Nimbostratus
iRule for App Offline
We currently use an iRule to display an app offline page when the connection to the server is down.
I would like to some how to make this as generic as possible due to wanting to use host headers.
He...
Hectorm
Nimbostratus
Irule name: Irule_XXXXX.xxxxx.org Programmed by Hector Morrell Programmed date: Programmed update: Programmed update by: type of update: Description:
when HTTP_REQUEST {
set the host name and url to lower case
set Vuri [ string tolower [HTTP::uri]]
set Vheader [string tolower [HTTP::host]]
set the Poolname variable.
set Poolname "pl_abc.123.com"
set poolname2 "pl_def.123.com"
set poolname3 "ghi.123.co"
set the default site name variable
set SiteName "XXXX.MAINTENANCEPAGE.org"
set Irulename "Irule_$SiteName"
set SiteRedirect "https://$SiteName"
Obtain active poolmembers count and list
set Poolmember [active_members $Poolname ]
set Poolmemberlist [ active_members -list $Poolname]
set Poolmember2 [active_members $Poolname2 ]
set Poolmemberlist2 [ active_members -list $Poolname2]
set Poolmember3 [active_members $Poolname3 ]
set Poolmemberlist3 [ active_members -list $Poolname3]
redirect to maintenance page if poolmembers count is zero
switch $Vheader {
abc.123.com {
if {$Poolmember < 1} then {
log local0.alert "ALERT-TEAM Pool $Poolname is down. This mean $SiteName website is down. IRULE=$Irulename";
HTTP::redirect "http://www.YOURPAGE-OFFLINE.COM"
} else {
pool $Poolname
}
}
def.123.com {
if {$Poolmember2 < 1} then {
log local0.alert "ALERT-TEAM Pool $Poolname is down. This mean $SiteName website is down. IRULE=$Irulename";
HTTP::redirect "http://www.YOURPAGE-OFFLINE.COM"
} else {
pool $Poolname2
}
}
ghi.123.com {
if {$Poolmember3 < 1} then {
log local0.alert "ALERT-TEAM Pool $Poolname is down. This mean $SiteName website is down. IRULE=$Irulename";
HTTP::redirect "http://www.YOURPAGE-OFFLINE.COM"
} else {
pool $Poolname3
}
}
default { HTTP::redirect "$SiteRedirect"}
}
}
if the server sends a 500 error code log the error and redirect to maintenance page
when HTTP_RESPONSE {
switch [HTTP::status] {
500 { log local0.alert "The servers is sending back a 500 Error: "
HTTP::redirect "http://www.benaroyaresearch.org.s3-website-us-west-2.amazonaws.com/"
}
502 { log local0.alert "The servers is sending back a 502 Error: "
HTTP::redirect "http://www.benaroyaresearch.org.s3-website-us-west-2.amazonaws.com/"
}
503 { log local0.alert "The servers is sending back a 503 Error: "
HTTP::redirect "http://www.benaroyaresearch.org.s3-website-us-west-2.amazonaws.com/"
}
}
}
Hectorm
Aug 16, 2017Nimbostratus
The second part of the Irule is only if you get a 50X error from the server. you do not need that part. Hope this help
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects