Forum Discussion
Maintenance/sorry page with image on v11.1
The way we used to do it is this:
"when HTTP_REQUEST {
Check active members of pool, if 0 respond with Apology Page.
if { [active_members your_pool] == 0 } {
HTTP::respond 200 content {
Apology Page
We are sorry, but the site you are looking for is temporarily out of service
If you feel you have reached this page in error, please try again.
}
}
}
"
To get a logo in the html, we just had to put it in a path and call it out. With iFiles, I understand, we call it with the "HTTP::response" 200 command. Since I already use it to create the html page, it seems I cant use it again for the logo picture call. I created this iRule for the new sorry page:
"when HTTP_REQUEST {
Set global variables.
set VSPool [LB::server pool]
set logo [ifile get logo.png]
Check for active members in the associated pool and respond with html content when the pool members are less than 1
if { [active_members $VSPool] < 1 } {
HTTP::respond 200 content {
Maintenance Page
The page you are trying to access our web site, we are currently unavailable due to maintenance. We apologize for the inconvenience. If you need to reach us, please call 1-800-123-1234 or email . If you are a customer and need to access our Support Web site, please go to http://support.domain.com.
}
}
}"
I have tried to call the "$logo" variable inside of the html as well as the "[ifile get logo.png]" command but it doesnt work. I even tried to add an "IF" statement before the html "IF" but all it does then is show the logo, no text.
ideas?
TIA
22 Replies
- JRahm
Admin
For those interested, I wrote this up a while back:
https://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/1086514/v111ndashExternal-File-Access-from-iRules-via-iFiles.aspx - pawel_jakacki_7
Nimbostratus
Hi Guys,
is there any possibility to make a such maintenance page using css? I've tried, but with no success.
when HTTP_REQUEST {
if {[active_members [LB::server pool]] < 1} {
if {[HTTP::uri] eq "/"} {
HTTP::respond 200 content [ifile get "index"]
} elseif {[HTTP::uri] eq "/file1.gif"} {
HTTP::respond 200 content [ifile get file1"]
} elseif {[HTTP::uri] eq "/style.css"} {
HTTP::respond 200 content [ifile get "style"]
} elseif {[HTTP::uri] eq "/file2.jpg"} {
HTTP::respond 200 content [ifile get file2"]
} elseif {[HTTP::uri] eq "/file3.jpg"} {
HTTP::respond 200 content [ifile get "file3"]
} else { discard }
}
}
File1 is directly referenced in the index.html and is displayed correctly, other files have reference in style.css file, which has no effect.
Paul - Kevin_Stewart
Employee
Paul, if you're receiving the CSS file, I would put log statements throughout to see what or if the CSS-referenced objects are being called. - pawel_jakacki_7
Nimbostratus
I've moved css into index.html file, and it works smoothly but only in Internet Explorer, in Firefox I'm receiving raw html file. Do you have any idea how to fix it? - Kevin_Stewart
Employee
At the end of each HTTP::respond command, add the appropriate content-type header:
HTTP::respond 200 content [ifile get "file3"] "Content-Type" "image/jpeg" - pawel_jakacki_7
Nimbostratus
thanks Kevin, it helps. - dp_119903
Cirrostratus
I used the example above and it works...but it only works if the user is going to the home page. I'm not a web guy so bear with me, but what I'm trying to say is that if the user goes to:
and the site is down it redirects it to the apology page.
But if the user goes to www.site.com/site/default.aspx then it doesn't redirect. Is there a way to make it so if the user goes to "any" URL within the site that it will redirect to the apology page? I can actually make that work using a basic apology page, but I can't get it to work with this example that uses the ifile to call the image.
What I can get to work is:
...but that doesn't allow me to display an image.when LB_FAILED { if { [active_members [LB::server pool]] < 1 } { HTTP::respond 200 content [ifile get "sharepoint_apology"] } else { discard } }What I'm currently using is:
Thanks,when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1} { switch [HTTP::uri] { "/" { HTTP::respond 200 content [ifile get "sharepoint_apology"] } "/sharepoint_apology_pic" { HTTP::respond 200 content [ifile get "sharepoint_apology_pic"] } } } }David
- Dmitriy_Sysoev
Nimbostratus
Hi! You need to tell browser what is the content of your files. My examples: when HTTP_REQUEST { if { ([active_members /E_Click/clk2_app]) < 1 || ([active_members /E_Click/clk2_login]) < 1} { switch [string tolower [HTTP::uri]] { "/facebook.png" { HTTP::respond 200 content [ifile get "facebook.png"] "Content-Type" "image/jpeg" } "/link_separator.gif" { HTTP::respond 200 content [ifile get "link_separator.gif"] "Content-Type" "image/gif" } "/logo.gif" { HTTP::respond 200 content [ifile get "logo.gif"] "Content-Type" "image/gif" } "/logo2.gif" { HTTP::respond 200 content [ifile get "logo2.gif"] "Content-Type" "image/gif" } "/logo3.gif" { HTTP::respond 200 content [ifile get "logo3.gif"] "Content-Type" "image/gif" } "/logo4.gif" { HTTP::respond 200 content [ifile get "logo4.gif"] "Content-Type" "image/gif" } "/offline_click.jpg" { HTTP::respond 200 content [ifile get "offline_click.jpg"] "Content-Type" "image/jpeg" } "/ppl.jpg" { HTTP::respond 200 content [ifile get "ppl.jpg"] "Content-Type" "image/jpeg" } "/t.gif" { HTTP::respond 200 content [ifile get "t.gif"] "Content-Type" "image/gif" } "/twitter.png" { HTTP::respond 200 content [ifile get "twitter.png"] "Content-Type" "image/png" } "/vkontakte.jpg" { HTTP::respond 200 content [ifile get "vkontakte.jpg"] "Content-Type" "image/jpeg" } "/" { HTTP::respond 200 content [ifile get "click_not_available.htm"] "Content-Type" "text/html" } } } else { HTTP::respond 302 Location "https://xxxxxxxxxx.ru/" } }
- Brandon
Cirrostratus
Does anyone know if there is a limit on characters on maintenance page. If images can be used.
- jsdy_46483
Nimbostratus
File size limit: I remember reading 4Mb.
Getting the apology page for all pages instead of just "/": instead of "/" in the switch, make that clause the default; or instead of "/" in an "if" test, make that the final "else".
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