Maintenance/sorry page with image on v11.1

I have written maintenance pages in the past with ease. The examples Devcentral were very helpful. The problem with creating one now that I find are the “iFiles” introduction in v11.

The way we used to do it is this:

"when HTTP_REQUEST {

Check active members of pool, if 0 respond with Apology Page.

if { [active_members your_pool] == 0 } {

HTTP::respond 200 content {

Apology Page

We are sorry, but the site you are looking for is temporarily out of service

If you feel you have reached this page in error, please try again.

}

}

}

"

To get a logo in the html, we just had to put it in a path and call it out. With iFiles, I understand, we call it with the “HTTP::response” 200 command. Since I already use it to create the html page, it seems I cant use it again for the logo picture call. I created this iRule for the new sorry page:

"when HTTP_REQUEST {

Set global variables.

set VSPool [LB::server pool]

set logo [ifile get logo.png]

Check for active members in the associated pool and respond with html content when the pool members are less than 1

if { [active_members $VSPool] < 1 } {

HTTP::respond 200 content {

Maintenance Page

The page you are trying to access our web site, we are currently unavailable due to maintenance. We apologize for the inconvenience. If you need to reach us, please call 1-800-123-1234 or email . If you are a customer and need to access our Support Web site, please go to http://support.domain.com.

}

}

}"

I have tried to call the “$logo” variable inside of the html as well as the “[ifile get logo.png]” command but it doesnt work. I even tried to add an “IF” statement before the html “IF” but all it does then is show the logo, no text.

ideas?

TIA

Shoot,

It looks like I didn’t escape the code correctly. Sorry about that.

this is mine.

root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.19.252:http
    ip-protocol tcp
    mask 255.255.255.255
    pool foo
    profiles {
        http { }
        tcp { }
    }
    rules {
        myrule
    }
    snat automap
    vlans-disabled
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo
ltm pool foo {
    members {
        200.200.200.101:http {
            address 200.200.200.101
            session monitor-enabled
            state down
        }
    }
    monitor fake
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule myrule
ltm rule myrule {
    when HTTP_REQUEST {
   if {[active_members [LB::server pool]] < 1} {
      switch [HTTP::uri] {
         "/" { HTTP::respond 200 content [ifile get "index"] }
         "/f5-logo.jpg" { HTTP::respond 200 content [ifile get "logo"] }
      }
   }
}
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm ifile index
ltm ifile index {
    file-name index
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm ifile logo
ltm ifile logo {
    file-name logo
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file ifile index
sys file ifile index {
    checksum SHA1:73:dca073b6657b15686c98bf5c9d5fecefec461453
    create-time 2012-07-02:21:29:42
    created-by admin
    last-update-time 2012-07-02:21:52:02
    mode 33188
    revision 2
    size 73
    updated-by admin
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file ifile logo
sys file ifile logo {
    checksum SHA1:5960:613133dcd34ea47070f38eca13b414920ade82b8
    create-time 2012-07-02:21:26:25
    created-by admin
    last-update-time 2012-07-02:21:26:25
    mode 33188
    revision 1
    size 5960
    updated-by admin
}

this is mine.

root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.19.252:http
    ip-protocol tcp
    mask 255.255.255.255
    pool foo
    profiles {
        http { }
        tcp { }
    }
    rules {
        myrule
    }
    snat automap
    vlans-disabled
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo
ltm pool foo {
    members {
        200.200.200.101:http {
            address 200.200.200.101
            session monitor-enabled
            state down
        }
    }
    monitor fake
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule myrule
ltm rule myrule {
    when HTTP_REQUEST {
   if {[active_members [LB::server pool]] < 1} {
      switch [HTTP::uri] {
         "/" { HTTP::respond 200 content [ifile get "index"] }
         "/f5-logo.jpg" { HTTP::respond 200 content [ifile get "logo"] }
      }
   }
}
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm ifile index
ltm ifile index {
    file-name index
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm ifile logo
ltm ifile logo {
    file-name logo
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file ifile index
sys file ifile index {
    checksum SHA1:73:dca073b6657b15686c98bf5c9d5fecefec461453
    create-time 2012-07-02:21:29:42
    created-by admin
    last-update-time 2012-07-02:21:52:02
    mode 33188
    revision 2
    size 73
    updated-by admin
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list sys file ifile logo
sys file ifile logo {
    checksum SHA1:5960:613133dcd34ea47070f38eca13b414920ade82b8
    create-time 2012-07-02:21:26:25
    created-by admin
    last-update-time 2012-07-02:21:26:25
    mode 33188
    revision 1
    size 5960
    updated-by admin
}

So I take it the iFile for index is the html code and there is an href for /f5-logo.jpg?

yes, index is html and logo is jpeg.

ok. Thanks. I will try that.

ok, I set up the html page and it only shows the html code

Make sure you import the iFile correctly - have a look at this - DevCentral

If you haven’t already. I got mine to work with no problems.

Jeff

I went according to that posting. When I go to the VS, I see the html. I am wondering what I could have missed. I imported the files, then made the iFile reference in the iFiles section under iRules. I see the code as it is in the index_html file. It just doesn’t interpret as html code. it displays as text. I have done this before and it has worked fine.

Nevermind. Seems to be a problem with Firefox. IE seems to work just fine

For those interested, I wrote this up a while back:

Hi Guys,

is there any possibility to make a such maintenance page using css? I’ve tried, but with no success.

when HTTP_REQUEST {

if {[active_members [LB::server pool]] < 1} {

if {[HTTP::uri] eq “/”} {

HTTP::respond 200 content [ifile get “index”]

} elseif {[HTTP::uri] eq “/file1.gif”} {

HTTP::respond 200 content [ifile get file1"]

} elseif {[HTTP::uri] eq “/style.css”} {

HTTP::respond 200 content [ifile get “style”]

} elseif {[HTTP::uri] eq “/file2.jpg”} {

HTTP::respond 200 content [ifile get file2"]

} elseif {[HTTP::uri] eq “/file3.jpg”} {

HTTP::respond 200 content [ifile get “file3”]

} else { discard }

}

}

File1 is directly referenced in the index.html and is displayed correctly, other files have reference in style.css file, which has no effect.

Paul

Paul, if you’re receiving the CSS file, I would put log statements throughout to see what or if the CSS-referenced objects are being called.

I’ve moved css into index.html file, and it works smoothly but only in Internet Explorer, in Firefox I’m receiving raw html file. Do you have any idea how to fix it?

At the end of each HTTP::respond command, add the appropriate content-type header:

HTTP::respond 200 content [ifile get “file3”] “Content-Type” “image/jpeg”

thanks Kevin, it helps.

I used the example above and it works…but it only works if the user is going to the home page. I’m not a web guy so bear with me, but what I’m trying to say is that if the user goes to:

www.site.com

and the site is down it redirects it to the apology page.

But if the user goes to www.site.com/site/default.aspx then it doesn’t redirect. Is there a way to make it so if the user goes to “any” URL within the site that it will redirect to the apology page? I can actually make that work using a basic apology page, but I can’t get it to work with this example that uses the ifile to call the image.

What I can get to work is:

when LB_FAILED {
if { [active_members [LB::server pool]] < 1 } {
           HTTP::respond 200 content [ifile get "sharepoint_apology"]
    } else { discard } 
}

…but that doesn’t allow me to display an image.

What I’m currently using is:

when HTTP_REQUEST {
   if {[active_members [LB::server pool]] < 1} {
      switch [HTTP::uri] {
         "/" { HTTP::respond 200 content [ifile get "sharepoint_apology"] }
         "/sharepoint_apology_pic" { HTTP::respond 200 content [ifile get "sharepoint_apology_pic"] }
      }
}
}

Thanks,

David

Hi! You need to tell browser what is the content of your files. My examples: when HTTP_REQUEST { if { ([active_members /E_Click/clk2_app]) < 1 || ([active_members /E_Click/clk2_login]) < 1} { switch [string tolower [HTTP::uri]] { “/facebook.png” { HTTP::respond 200 content [ifile get “facebook.png”] “Content-Type” “image/jpeg” } “/link_separator.gif” { HTTP::respond 200 content [ifile get “link_separator.gif”] “Content-Type” “image/gif” } “/logo.gif” { HTTP::respond 200 content [ifile get “logo.gif”] “Content-Type” “image/gif” } “/logo2.gif” { HTTP::respond 200 content [ifile get “logo2.gif”] “Content-Type” “image/gif” } “/logo3.gif” { HTTP::respond 200 content [ifile get “logo3.gif”] “Content-Type” “image/gif” } “/logo4.gif” { HTTP::respond 200 content [ifile get “logo4.gif”] “Content-Type” “image/gif” } “/offline_click.jpg” { HTTP::respond 200 content [ifile get “offline_click.jpg”] “Content-Type” “image/jpeg” } “/ppl.jpg” { HTTP::respond 200 content [ifile get “ppl.jpg”] “Content-Type” “image/jpeg” } “/t.gif” { HTTP::respond 200 content [ifile get “t.gif”] “Content-Type” “image/gif” } “/twitter.png” { HTTP::respond 200 content [ifile get “twitter.png”] “Content-Type” “image/png” } “/vkontakte.jpg” { HTTP::respond 200 content [ifile get “vkontakte.jpg”] “Content-Type” “image/jpeg” } “/” { HTTP::respond 200 content [ifile get “click_not_available.htm”] “Content-Type” “text/html” } } } else { HTTP::respond 302 Location “https://xxxxxxxxxx.ru/” } }

I really like the fact that you are using a switch statement && iFiles to host all of the content on your maintenance page. Great stuff.