Forum Discussion
Host a HTML Maintenance Page on LTM
Here a complete maintenance irule with css, jpg, png and html payload :
when CLIENT_ACCEPTED {
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
if { [active_members $default_pool] < 1 } {
HTTP::respond 200 content [ifile get "/Common/maintenance.html"] noserver "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate"
return
}
switch -glob [string tolower [HTTP::path]] {
"*maintenance-logo.png" {
HTTP::respond 200 content [ifile get "/Common/maintenance-logo.png"] noserver "Content-Type" "image/png" "Cache-Control" "no-cache, must-revalidate"
}
"*maintenance.jpg" {
HTTP::respond 200 content [ifile get "/Common/maintenance.jpg"] noserver "Content-Type" "image/jpg" "Cache-Control" "no-cache, must-revalidate"
}
"*maintenance.css" {
HTTP::respond 200 content [ifile get "/Common/maintenance.css"] noserver "Content-Type" "text/css" "Cache-Control" "no-cache, must-revalidate"
}
}
}
when LB_FAILED {
HTTP::respond 200 content [ifile get "/Common/maintenance.html"] noserver "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate"
}
- Eddy_161863Jul 14, 2016
Nimbostratus
thanks I did...I uploaded it as a text file, it worked.
But it's not displaying the logo on the Page which we have as a part of maintenance page.
How can we use logo and text together?
I tried this but didn't work:
when HTTP_REQUEST { if { [active_members [LB::server pool]] == 0 } { HTTP::respond 200 content [ifile get maintenance.html] "Content-Type" "text/html" and [ifile get logo.png] "Content-Type" "image/gif"
} }
- Yann_Desmarest_Jul 14, 2016
Nacreous
Hi,
you have to follow how I built my irule for maintenance. in the maintenance.html file, you should have a reference to the logo like this :
and your irule should looks like this :
when HTTP_REQUEST { if { [active_members $default_pool] < 1 } { HTTP::respond 200 content [ifile get "/Common/maintenance.html"] noserver "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate" return } if { [string tolower [HTTP::path]] equals "/logo.png" } { HTTP::respond 200 content [ifile get "/Common/logo.png"] noserver "Content-Type" "image/png" "Cache-Control" "no-cache, must-revalidate" } } - Eddy_161863Jul 15, 2016
Nimbostratus
I tried this but didn't work..... for the logo I still see a 'X' there.
Why are you using '/Common' before the iFile like /Common/logo.png.
Is there any other way to provide reference to the logo? like I don't want to use another 'If' statement. Can it be integrated in one 'if' statement - both Image and HTML?
Like if I use only logo IF statement, it works and if I use only HTML IF statement, it works but if I use both together, Image doesn't come up.
Any help??
- Yann_Desmarest_Jul 15, 2016
Nacreous
Hi,
/Common match the partition. Common is the default partition, but if you have more than one partition, you need to specify the partition the object belong to in the irule.
Doing a request to the Virtual Server, you can answer with a single response. You can avoid the query to the logo if you integrate the image to the html content. You have to replace the img tag by following :
Note that the image must be base64 encoded.
Moreover, using the first scenario, I think you should change the if order in the irule :
when HTTP_REQUEST { if { [string tolower [HTTP::path]] equals "/logo.png" } { HTTP::respond 200 content [ifile get "/Common/logo.png"] noserver "Content-Type" "image/png" "Cache-Control" "no-cache, must-revalidate" return } if { [active_members $default_pool] < 1 } { HTTP::respond 200 content [ifile get "/Common/maintenance.html"] noserver "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate" return } } - Eddy_161863Jul 15, 2016
Nimbostratus
great- that worked with minor changes. thank you so much for your help!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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