Forum Discussion
Maintenance Page Needed.
Hello, all.
A customer is requesting that a maintenance page be displayed for their VIP when their pool members are down. They have provided the HTML code with some Base64 embedded images.
I'm just wondering what the most effective/efficient/easiest way to implement this is? I tried searching, but I came across some overly complicated irules that I don't believe I need.
Some tips/direction would be greatly appreciated.
Thanks.
- Kevin_StewartEmployee
Something like this is probably still your best bet:
https://devcentral.f5.com/wiki/irules.automatic_maintenance_page___sorry_page_with_images.ashx
Except that you don't really need to keep the images in base64 anymore. You can upload the raw images into iFiles and call them directly. You can also store the base64-encoded images in an internal or external data group and use the 'class' command to fetch them. The below is a modified example using iFiles.
when HTTP_REQUEST { if { [active_members [LB::server pool]] < 1 } { if { [HTTP::uri] ends_with "logo.png" } { HTTP::respond 200 content [ifile get logo] "Content-Type" "image/png" } elseif { [HTTP::uri] ends_with "background.png" } { HTTP::respond 200 content [ifile get background] "Content-Type" "image/png" } else { HTTP::respond 200 content "HTML blocking page content" } } }
So basically, your HTML document is going to include image directives (src tags), which should include relative URLs (ex. "./logo.png"). When all pool members are down, the first action will be to send the HTML page (the else condition). The browser will then make separate requests for the embedded src tag images, which the above iRule will respond with.
You could also technically embed the images directly into the HTML document using "data:image/png;base64" syntax. See https://varvy.com/pagespeed/base64-images.html for a good reference. In that case you'd just need a single, albeit large, HTML file to send.
- Kevin_StewartEmployee
Even simpler:
when HTTP_REQUEST { if { [active_members pool_1] < 1 } { HTTP::respond 200 content [ifile get "MaintenancePage.html"] noserver "Content-Type" "text/html" "Cache-Control" "no-cache, must-revalidate" } }
There's likely no reason to qualify the request URI here. Otherwise what would you do if the request URI wasn't "/" and all pool members were down?
- Kevin_StewartEmployee
Are you using iFiles? That's what I'd recommend.
Ref:
https://devcentral.f5.com/wiki/iRules.iFile.ashx
- Kevin_StewartEmployee
Okay, so there are two things you need to do:
-
Upload the file - under System - File Management - iFile List, click to import.
-
Import the iFile to LTM - under Local Traffic - iRules - iFile List, click to Create. Give it a name and select the previously-imported iFile.
Now in your iRule, use the name that you provided to LTM to access your iFile.
-
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