Forum Discussion

gdoyle's avatar
gdoyle
Icon for Cirrostratus rankCirrostratus
Sep 24, 2018

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.

 

4 Replies

  • 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.

  • 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?

  • Okay, so there are two things you need to do:

     

    1. Upload the file - under System - File Management - iFile List, click to import.

       

    2. 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.