Hosting Static Content with an iRule and iFiles

If you didn’t know about this feature it is a neat trick to host maintenance pages.  I’ve recently implemented this to host a static website on the BIG-IP without the need for a backend web server.  The use case I’m looking at is for F5 training labs running in Google’s Cloud Compute Engine via Ravello.  We’ll be running anywhere from 30 to 50 training instances so to keep costs down I only want to run an F5 image.

I used the HTML5 Initializr tool to generate a responsive web application shell and them customized with the traditional F5 red and information about using an iRule and iFiles to host content.

Demo Page
Demo Page

To host this content i created an ifile folder on the BIG-IP in the config director then I uploaded the HTML, CSS and Javascript files to it.  From here I used TMSH to create the iFile butyou can also use the GUI. Example below for main.css:

create sys file ifile main.css source-path file://localhost/config/ifile/main.css
create ltm ifile main.css file-name main.css

I then created the following iRule and assigned it to my test virtual server:

  switch [HTTP::uri] {
    "/" -
    "/index.html" {
      HTTP::respond 200 content [ifile get index.html]
    "/js/vendor/jquery-1.11.2.min.js" {
      HTTP::respond 200 content [ifile get jquery-1.11.2.min.js]
    "/img/f5-logo-solid-rgb.png" {
      HTTP::respond 200 content [ifile get f5-logo-solid-rgb.png]
    "/css/main.css" {
      HTTP::respond 200 content [ifile get main.css]
    "/js/vendor/modernizr-2.8.3-respond-1.4.2.min.js" {
      HTTP::respond 200 content [ifile get modernizr-2.8.3-respond-1.4.2.min.js]
    "/css/normalize.min.css" {
      HTTP::respond 200 content [ifile get normalize.min.css]

Easy enough!

Tar file of the demo site and iRule here:demo_site

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.