01-Dec-2017
12:10
- last edited on
28-Nov-2022
14:58
by
JRahm
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:
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.
01-Dec-2017 14:18
If you wish to have no hassle of iFile, you can encode logo as text and emded. eg.
<--img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAADSCAMAAABThmYtAAAAXVB">
https://varvy.com/pagespeed/base64-images.html
04-Dec-2017 05:46
Thanks for your suggestion but this will be useful only for smaller images.
08-Oct-2018 00:06
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.
08-Oct-2018 03:40
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
08-Oct-2018
03:53
- last edited on
28-Nov-2022
14:59
by
JRahm
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.
08-Oct-2018 04:19
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