Search
Jason Rahm - Jason's Blog
You are here: DevCentral > Weblogs

posted on Tuesday, May 12, 2009 11:18 AM

It's not an uncommon problem trying to figure out where to plant that sorry page in the event your farm is down.  It's also not an uncommon solution to just use your BIG-IP to issue a text-only HTTP::respond.  It works, but it's not, how do you say, visually appealing?  You want to say sorry and mean it.  With pictures.  If you take a stroll through the iRules codeshare, you'll notice several solutions to this problem.  All of them work, with a variety of msorryethods, but user kirkbauer's entry takes it to another level.  Kirk's sorry page irule generator (written in perl) takes all the guess work out of the process for you.  Dump the perl script in /var/tmp, give execute permissions to root, and off you go.  Here's a sample configuration, just taking Google's main page:

[root@ltm01:Active] mibs # /var/tmp/sorrygen.pl

Welcome to the F5 Sorry Page iRule Generator

This script will create a sorry page iRule based on an arbitrary web page.

This script can download the sorry page from the specified URL (you may need to use an IP address instead of a hostname if you don't have DNS set up) or it can convert a page (and all includes) already in a local directory.

Enter the prefix pathname (such as 'sorrypage') for a directory that doesn't exist in your app (do not include any slashes):
sorrypage

Please provide the URL (starting with http://) or local directory with the sorry page:
http://www.google.com
Downloading http://www.google.com/
Downloading http://www.google.com//intl/en_ALL/images/logo.gif
Checking included object /index.html: is text.
Checking included object /sorrypage/intl/en_ALL/images/logo.gif: is an image.

Done.
Completed files can be found in /tmp/irulegen-18583/output/.

Do you want to deploy this iRule and associated data groups now?[Y/n]:
Y

The following partitions were found: Common ops1 ops2

Which partition do you want to install this in?:
ops2

** Backing up /config/bigip.conf as /config/bigip.conf.bak
Saving current config.
/config/bigip.conf was renamed to /config/bigip.conf.bak (492 lines).
/config/bigip_local.conf was renamed to /config/bigip_local.conf.bak (3 lines).
/config/bigip_sys.conf was renamed to /config/bigip_sys.conf.bak (32 lines).
Modified bigip.conf
Placed /var/class/sorrypage.index.html.class
Placed /var/class/sorrypage.intl.en_ALL.images.logo.gif.class
Loading new config.
Reading configuration from /defaults/config_base.conf.
Reading configuration from /config/bigip_base.conf.
Reading configuration from /config/bigip_sys.conf.
Reading configuration from /usr/bin/monitors/builtins/base_monitors.conf.
Reading configuration from /config/profile_base.conf.
Reading configuration from /config/daemon.conf.
Reading configuration from /config/bigip.conf.
Reading configuration from /config/bigip_local.conf.
Loading the configuration ...

Rule should be ready to go -- just apply the iRule 'sorry_page_sorrypage' to one or more virtual servers.

Pretty easy, right?  I allowed the script to deploy--here's the iRule:

Sorry Page iRule

 

rule sorry_page_sorrypage {
   # Auto-generated by sorry_irule.pl
  when HTTP_REQUEST {
    #
    # Service requests for files (URIs) from the maintenance page
    # Note that we always service these pages, even if the http_pool is up
    #
    set uri [HTTP::uri]
    if { $uri equals "/sorrypage" } {
       HTTP::respond 301 "Location" "/sorrypage/"
       return
    }
    if { $uri starts_with "/sorrypage/" } {
       # trim off the maintenance prefix
       set uri [string range $uri 10 end]

       # Return the requested page
       switch $uri {
         "/"              -
         "/index.html"   { HTTP::respond 200 content [lindex $::sorrypage_index_html 0] "Content-Type" "text/html" }
         "/intl/en_ALL/images/logo.gif"   { HTTP::respond 200 content \
		 [b64decode [lindex $::sorrypage_intl_en_ALL_images_logo_gif 0]] "Content-Type" "image/gif" }
         default         { HTTP::respond 404 }
       }
       return
    }

    #
    # If the http_pool is down, redirect to the maintenance page
    #
    if { [active_members [LB::server pool]] < 1 } {
      HTTP::redirect "/sorrypage/index.html"
      return
    }
  }
   partition ops2
}

 

 

Definitely the way to go if you plan on hosting your sorry page on the BIG-IPClick here for the code.

 

Follow me on Twitter Follow me on LinkedIn Follow me on Facebook Add to Technorati Favorites

 



Feedback

5/28/2009 2:50 AM
Gravatar We had some issues with the irule that was automatically generated. We are ran it on v10.

The issue we had was instead of displaying the sorry page it instead was displaying the text "sorrypage_index_html".

We resolved the issue by using the "class element 0" function instead of "lindex $::". This is discussed in the thread below.

http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=2309

chris achis
7/7/2009 3:55 AM
Gravatar Hi. This is brilliant :) I couldnt quite get it to work with images referenced in the css so one of our coders cleaned the script up a bit. email me if that is of any interest. But i was wondering something; When using multiple pools (traffic is directed based on url and/or host with httpclasses), can I configure the irule to show the maintenance page for only one of these pools? Right now it seems like the irule will only redirect if the default pool has no healthy members...

ingard
ingard
7/7/2009 7:17 AM
Gravatar @chris - The rule was originally written for v9. In v10, classes are called in a new way as you have already figured out, with the class command. So all rules with class references moving forward from v9 to v10 will need to be converted

@ingard - If you like, you can send your version to devcentral-at-f5-dot-com and I'll get it posted and linked from the wiki page. Re: the pool behavior...that is the way the iRule is configured, to only redirect to the sorry page when the pool has no active members. You can rewrite the rule to apply for other times as well, such as maintenance windows. To incorporate those concepts, you can take a look at this wiki page:

http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenanceWindow.html
Jason Rahm
1/4/2010 5:45 AM
Gravatar Kirk updated the script to auto-detect TMOS v10 and adjust accordingly. Links in the above post point to the new script. Thanks Kirk!
Jason
12/3/2010 11:54 AM
Gravatar I've used this script to import a simple maintenance page but it didn't import an our corporate logo. Are there any special requirements for images?

Also, the LTM inserts a "{" at the beginning of the page and "} {}" at the end of the page.

Has anyone else run into this? Is there an easy workaround/fix?

Thanks.
Jason S.
12/16/2010 9:57 AM
Gravatar Has anyone had an issue with this iRule adding a "{" at the top left of the sorry page and "} {}" at the bottom left of the sorry page? These characters don't show up in the index page or any of the associated files but always show up in the page source in the browser.

The page also does not display images, but this could be a side effect of the issue above.

Thanks for any help...
Jason S.
2/9/2011 7:17 AM
Gravatar Hi Everyone,

I'm having the same Problem with LTM v10.2 HF2 1755.1, has anyone have a workarround for this issue, before migrating from v9 to v10.2 the Sorry Page was displayed with images and everything, but now only the text is shown and "{" is added at the top left of the sorry page and "} {}" at the bottom left of the sorry page.

Thks
DonDiego
6/14/2011 3:24 AM
Gravatar Hi,

Can this be tested on the LTM virtual appliance (v10)?

Thanks
JoeTheFifth
1/18/2012 1:32 PM
Gravatar with v11.1, iFiles makes this really easy. I wrote an article on their use for a maintenance page:

devcentral.f5.com/.../...om-iRules-via-iFiles.aspx
jason
1/18/2012 10:46 AM
Gravatar Hi, this feature is really exciting, is it planed to adapt it for v11 ? :D
Cyril

Let Me Know What You Think


Please use the form below if you have any comments, questions, or suggestions.

Title:
 
Name:
 
Email: (so we can show your gravatar)
Website:
Comment: Allowed tags: blockquote, a, strong, em, p, u, strike, super, sub, code
 
Please add 7 and 7 and type the answer here:

Blog Stats

Posts:86
Comments:108
Stories:0
Trackbacks:0
  

82,243 Members in 102 Countries and Growing!

Join DevCentral Today!

About DevCentral

DevCentral has been a successful, thriving community for many years. We have always strived to bring you the best technical documentation, discussion forums, blogs, media and much more that we can.

So dive in, get familiar with DevCentral. We hope you like it, we hope it makes your job easier, and lets you get that much more power out of the community. To learn more, make sure to check out the Getting Started section. And if you have any problems, or think something could be easier to use, drop us a line to let us know.

Got It !

We've received your comment and transmitted it directly to DevCentral HQ.

Thanks for taking time to let us know what's on your mind. At DevCentral | Community Matters!

Get In Touch With Us

Have questions, suggestions or just want to get something off your chest?

Use our handy form below to Direct Connect with DevCentral Mission Control.

Send Us Feedback       or