For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

alex100's avatar
alex100
Icon for Cirrostratus rankCirrostratus
Jun 21, 2016

Help with maintenance page iRule needed

Hi all, I am working on migration of static maintenance page from stand alone web server to Big-IP. I am sucessfully using iRule below to compile a static page using content uploaded to iFile.

    when HTTP_REQUEST {
    switch [HTTP::uri] {
        "/main.css" {
            HTTP::respond 200 content [ifile get main.css] "Content-Type" "text/css"
        } 
        "/image001.jpg" {
            HTTP::respond 200 content [ifile get image002.jpg] "Content-Type" "image/jpg"
        }
    "/home_bkgrd.gif" {
                HTTP::respond 200 content [ifile get home_bkgrd.gif] "Content-Type" "image/gif"
        }
    "/logo.gif" {
                HTTP::respond 200 content [ifile get logo.gif] "Content-Type" "image/gif"
        }
    "/corporatenav_bkgrd.gif" {
                HTTP::respond 200 content [ifile get corporatenav_bkgrd.gif] "Content-Type" "image/gif"
        }
    "/main_bkgrd.gif" {
                HTTP::respond 200 content [ifile get main_bkgrd.gif] "Content-Type" "image/gif"
        }
    "/logo_print.gif" {
                HTTP::respond 200 content [ifile get logo_print.gif] "Content-Type" "image/gif"
        }
        default {
            HTTP::respond 200 content [ifile get index.htm] "Content-Type" "text/html"
        }
    }
}

I have also uploaded a alternative version of index.htm (index2.htm) that contains slightly different maintenance page message. Challenge is that I need to alternate between index.htm and index2.htm depending on request URI. So per say when request URI eq /companyA index2.htm is served but for any other URI index.htm is served by iRule. Any help is greatly appreciated.

1 Reply

  • Hi,

     

    you can change some part of your code as below :

     

    default {
        if { [HTTP::path] eq "/companyA" } {
            HTTP::respond 200 content [ifile get index2.htm] "Content-Type" "text/html"
        } else {
            HTTP::respond 200 content [ifile get index.htm] "Content-Type" "text/html"
        }
    }

    If you have several uri to include, you can use a datagroupv:

     

    default {
        if { [class match [HTTP::path] URI_DATAGROUP] } {
            HTTP::respond 200 content [ifile get index2.htm] "Content-Type" "text/html"
        } else {
            HTTP::respond 200 content [ifile get index.htm] "Content-Type" "text/html"
        }
    }