Forum Discussion

HarshaPotharaju's avatar
HarshaPotharaju
Icon for Nimbostratus rankNimbostratus
Dec 01, 2017

Solution: Create a F5 Maintenance Page with Image (iRule/iFile) - A step by step procedure.

I have read many articles, questions and solutions to create a maintenance page and publish that page with an image when all members in a pool are down, I found it is not that easy, So I would like to combine all that stuff and put them in one place to make it more understandable.

I am going to use HTML code directly in the iRule rather than uploading as an 'iFile' to show you in detail.

Prerequisite: An image with any format. Example: mylogo.png

Procedure:

  1. Navigate to System > File Management > iFile List and Click on Import and upload an Image with name mylogo.png (or you can name it as 'mylogo' but make sure you should use same in the entire process)
  2. Navigate to Local Traffic > iRules > iFile List and Click on Create and enter name 'mylogo.png' and select 'mylogo.png' from the drop down list.
  3. Now Create an iRule (see below) and attach it to the respective Virtual Server and test it by disabling all members in the pool.
  4. You can change HTML code in the iRule as per your requirement but make sure you define in the HTML body.

            when HTTP_REQUEST {
            if { [active_members [LB::server pool]] < 1 } {
            switch [HTTP::uri] {
    
            "/mylogo.png" {HTTP::respond 200 content [ifile get "mylogo.png"]}
    
            default {HTTP::respond 200 content {
    
            
            Site Maintenance
            
    
            
            
            We’ll be back soon!
            
            Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always , otherwise we’ll be back online shortly!
            — IT Security
            
            
    
            }
          }
        }
      }
    }
    
  5. OPTIONAL: You can also HTML code as the ifile like 'mylogo.png'. For that, you must follow same procedure from the beginning. Then you will have 'mypage.html' and 'mylogo.png' in your iFile list. Then create your iRule as below. The drawback for this is, you cannot change the HTML code instantly like in the above iRule. For every change you need to upload HTML file as an ifile.

    when HTTP_REQUEST {
    if {[active_members [LB::server pool]] < 1} {
    
        switch [HTTP::uri] {
             "/mylogo.png" {HTTP::respond 200 content [ifile get "mylogo.png"] }
    
             default {HTTP::respond 200 content [ifile get "mypage.html"] }
            }
        }
    }
    

That is it. Any ideas/suggestions would be highly appreciated.

Thank you,

Harsha Potharaju.

  • Hi,

    How can we automate this maintenance page configuration please?

    Thanks

  • You need an internal datagroup of string type. Put the filename ( eg logo.jpg ) as the key and the base64 encoded text as the value.

     

  • under datagroup what type i needs to select like external file or string

     

    and if its string then what for string i put and value

     

  • You want to create an internal datagroup called maintenance and add the filename as a key and the base64 string as the value.

     

    when HTTP_REQUEST {
        set image [class match -value -- [URI::basename [HTTP::uri]] equals maintenance]
        if { $image != "" } {
            HTTP::respond 200 content [b64decode $image]
        }
    }
    

     

    I suspect that you would have to set the Content-Type header correctly so that the browser can interpret the file correctly.

  • so I already stored base64 string of my image under /var/class/maintenance_html.class

     

    And also created irule Datagroup.

     

    What Irule i needs to have to call image from /var/class so that it can appear as maintenence page

     

  • Korai - store the string in a datagroup with the key as the filename and retrieve it from there.

     

  • thanks,

     

    how to create irule to call base64 string image for maintenance page. above irules are for ifile used for version 11 and above. we have version 10.