Forum Discussion

Chris_Chaloux_1's avatar
Chris_Chaloux_1
Icon for Nimbostratus rankNimbostratus
Dec 03, 2008

LTM Maint. Page issue

All -

I am trying to set up the LTM Maintenace Page example and I'm running into an issue. I have set up the rule exactly as described in the document (http://devcentral.f5.com/Wiki/default.aspx/iRules/LTMMaintenancePage.html).

The issue I am having is that instead of the lindex html stream being returned, it is returning the location of the class file to the browser. When I invoke the rule by going after the VIP from my browser, the only display I get is:

/var/class/maint.index.html.class

Thats it! It seems like either a variable isnt being invoked correctly, or for some reason it is interpreting the call to the class file as a literal.

My iRule reads like this:

  
  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 maint_prefix "/maintenancepage"  
      set maint_len [string length $maint_prefix]  
      set uri [HTTP::uri]  
  log local0. "redirect: [HTTP::uri]"  
  if { $uri equals ${::maint_prefix} } {  
         HTTP::respond 301 "Location" "${::maint_prefix}/"  
         return  
      }  
      if { $uri starts_with "${::maint_prefix}/" } {  
          trim off the maintenance prefix  
         set uri [string range $uri $::maint_len end]  
           
          Return the requested page  
  log local0. "respond: [lindex $::maint_index_html 0]"  
  switch $uri {  
           "/"              -  
           "/index.html"   { HTTP::respond 200 content [lindex $::maint_index_html 0]           "Content-Type" "text/html" }  
           "/logo.png"     { HTTP::respond 200 content [b64decode [lindex $::maint_logo_png 0]] "Content-Type" "image/png" }  
           default         { HTTP::respond 404 }  
         }  
  return  
      }  
        
       If the all members in the default pool are down, redirect to the maintenance page  
        
      if { [active_members [LB::server pool]] < 1 } {  
        HTTP::redirect "${::maint_prefix}/index.html"  
        return  
      }  
    }  
  

Does anyone see whats going on? This is driving me nuts!!

Thanks,

Chris

15 Replies

  • Hi All,

     

    I have a new update, I successfully copy and create the irules, but my webpage show this:

     

    maint_index_html_class

     

    Not the maintenance page that I created,

     

    Please help..

     

    Thanks
  • Hi Aaron,

     

    I'm using LTM BIG-IP 10.0.1 Build 378.0 Hotfix HF3, now I successfully created the irules but, the html page show only:

     

    maint_index_html_class

     

  • Hi Aaron,

     

    I do b class list all

     

    below is the result:

     

    class maint_index_html_class {

     

    type string

     

    timestamp 2010-11-23 09:36:52

     

    filename "/var/class/maint.index.html.class"

     

    mode rw

     

    separator ":="

     

    partition Common

     

    "Maintenance page

     

    Sorry! This site is down for maintenance."

     

    }

     

     

    class maint_logo_png_class {

     

    type string

     

    timestamp 2010-11-23 15:23:48

     

    filename "/var/class/maint.logo.png.class"

     

    mode rw

     

    separator ":="

     

    partition Common

     

    {

     

    " "

     

    "iVBORw0KGgoAAAANSUhEUgAAAL4AAAC3AgMAAADRFQzGAAAACVBMVEUAAADDAAD///8UoaPIAAElFTkSuQmCC"SLUHbWwzRlvrS1spJalnVcanB9Evvj8aLuZ3BX1Y1P+AUbgLzbWCp20NpfmAAAA

     

    }

     

    }

     

     

    anything wrong in the class?

     

     

    the irules as below:

     

    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.

     

    The maintenance prefix should be unique in the application and

     

    not conflict with an existing directory on the web servers.

     

    set maint_prefix "/maintenancepage"

     

     

    if { [HTTP::uri] starts_with "$maint_prefix" } {

     

     

    Strip off the $maint_prefix from the URI as you can't easily do variable expansion

     

    within a switch statement.

     

    Note that requests for the exact maintenance prefix URI will be set to a null string,

     

    so handle null in the first switch case.

     

    set uri [string map [list $maint_prefix ""] [HTTP::uri]]

     

     

    Return the requested page based on the requested URI

     

    switch -- $uri {

     

    "" {

     

    log local0. "Request for $maint_prefix. Redirecting to $maint_prefix/"

     

    HTTP::redirect "$maint_prefix/index.html"

     

    }

     

    "/" -

     

    "/index.html" {

     

    log local0. "Request for index. Responding with content: [lindex $::maint_index_html_class 0]"

     

    HTTP::respond 200 content [lindex $::maint_index_html_class 0] "Content-Type" "text/html"

     

    }

     

    "/logo.png" {

     

    log local0. "Request for logo.png. Responding with binary content"

     

    HTTP::respond 200 content [b64decode [lindex $::maint_logo_png_class 0]] "Content-Type" "image/png"

     

    }

     

    default {

     

    log local0. "Unrecognized request to URI: [HTTP::uri]"

     

    HTTP::respond 404 content "Unrecognized request to [HTTP::uri]" "Content-Type" "text/html"

     

    }

     

    }

     

    return

     

    }

     

     

    If the all members in the default pool are down, redirect to the maintenance page

     

     

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

     

    HTTP::redirect "$maint_prefix/index.html"

     

    }

     

    }

     

  • Hi Nit,

     

     

    In 10.x, referencing the datagroup using $::datagroup_name will just return the datagroup name--not the contents. So you can change the [lindex $::datagroup_name 0] commands to:

     

     

    [class element -value 0 datagroup_name]

     

     

    Also, I'd suggest upgrading to 10.2.1 once it's released as it contains a lot of fixes and enhancements over 10.0.1.

     

     

    Aaron