fir3net
PPS-Firenetbanner-780.5x190-30-03-17

BigIP F5 LTM - How to Create a Sorry Page with Image

Within this article we will show you the necessary steps required to create a sorry page (containing an image) that will be published when there are no available pool memebers for the spefic VIP (Virtual Server).

Note : This example is based upon serving a png image.

Encode Image

First of the image that will used within the sorry page needs to be base64 encoded.
To do this copy the image over to the F5`s directory /var/tmp and name it holding_page.png. The easiest way to copy the file over is by using a scp client (such as Putty`s pscp).

The following command will base encode the image into the file /var/class/image.class.

Note : The following command should be copied to the F5 shell as a single line.

echo \"sorryimage\" \:\= \"`base64 /var/tmp/holding_page.png | xargs echo | sed 's/ //g'`\"\, > /var/class/image.class

This should result in a file being created that has the following layout,

[root@f5-ltm:Active] config # head /var/class/image.class
"sorryimage" := "iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAMAAACNZOU/A ...... remaining output omitted.

Create Data Group

Next we need to create a Data Group referencing this encoded image. This is done by using the following command,

cat >> bigip.conf

<PASTE THE FOLLOWING>
class sorryimage {
type string
filename "/var/class/image.class"
separator ":="
}
<CTRL-C>

Create the iRule

We next add the iRule and then load the new configuration.

cat >> bigip.conf 

<PASTE THE FOLLOWING>
rule IRULE-SORRYPAGE {
   when HTTP_REQUEST {
       if { [active_members [LB::server pool]] < 1 }
          { HTTP::respond 200 content [b64decode [class element -value 0 sorryimage ]] "Content-Type" "image/png" }
       }
    }
<CTRL-C>

b load

Assign iRule

Finally we assign the iRule named 'IRULE-SORRYPAGE' to the required Virtual Server.

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001