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:
- 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)
- 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.
- Now Create an iRule (see below) and attach it to the respective Virtual Server and test it by disabling all members in the pool.
-
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 } } } } }
-
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.