Forum Discussion

ramki_75145's avatar
ramki_75145
Icon for Nimbostratus rankNimbostratus
Dec 19, 2007

maintenance messages

I'm new to iRules and trying to create iRule for different HTTP status codes and serverdown condition.

 

I took some of the code from other posts in this form. Here is the iRule i got. I'm getting error messages when i'm saving this iRule in F5. Could someone please help in fixing these error messages.

 

--------------------------------------

 

when RULE_INIT {

 

 

set error_404 {

 

 

 

 

 

Sorry, but the page you requested could not be found.

 

 

Please check that the requested page was typed properly and try again.

 

 

 

 

}

 

 

set Servers_down {

 

 

 

 

 

Sorry, Servers are currently down for maintenance.

 

 

Please check back in 10 minutes.

 

 

 

 

}

 

}

 

 

 

when HTTP_RESPONSE {

 

 

if {[active_members [LB::server pool]] == 0}

 

{

 

HTTP::respond 200 content [subst $::Servers_down]

 

}

 

else {

 

if { [HTTP::status] != 401 }

 

{

 

if { [HTTP::status] == 404 }

 

{

 

HTTP::respond 200 content [subst $::error_404]

 

}

 

else {

 

if { [HTTP::status] >= 500 }

 

{

 

HTTP::respond 200 content [subst $::Servers_down]

 

}

 

}

 

}

 

}

 

}

 

 

--------------------------------------

 

 

ERROR MESSAGES:

 

01070151:3: Rule [CASErrorCustomMessage] error:

 

line 34: [missing a script after "if"] [ ]

 

line 35: [undefined procedure:

 

if { [HTTP::status] == 404 }

 

{

 

HTTP::respond 200 content [subst $::error_404]

 

}

 

else {

 

if { [HTTP::status] >= 500 }

 

{

 

HTTP::respond 200 content [subst $::Servers_down]

 

}

 

}

 

] [{

 

if { [HTTP::status] == 404 }

 

{

 

HTTP::respond 200 content [subst $::error_404]

 

}

 

else {

 

if { [HTTP::status] >= 500 }

 

{

 

HTTP::respond 200 content [subst $::Servers_down]

 

}

 

}

 

}]

 

 

 

I appreciate your help. Thanks rk.

 

3 Replies

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Here's a cleaned up version of the same rule. See if this one runs any smoother.

    
    when RULE_INIT {
      set error_404 "
    Sorry, but the page you requested could not be found.
    Please check that the requested page was typed properly and try again."
      set Servers_down "
    Sorry, Servers are currently down for maintenance. Please check back in 10 minutes."
    }
    when HTTP_RESPONSE {
      if {[active_members [LB::server pool]] == 0} {
        HTTP::respond 200 content $::Servers_down
      } else {
        if { [HTTP::status] == 404 } {
          HTTP::respond 200 content $::error_404
        } elseif { [HTTP::status] >= 500 } {
            HTTP::respond 200 content $::Servers_down
        }
      }
    }

    Colin
  • Thank you Colin,

     

    with your changes to iRule, it is saved. But when application server is down, it is not showing maintenance message that we put in the IRule.

     

    Browser shows "The page cannot be displayed" message.

     

    could some one let me know how to show maintenance message in F5, when server is down/stopped?

     

     

    Thanks

     

    r
  • You won't see an HTTP_RESPONSE event from a server that isn't online. If you move the active members check into the HTTP_REQUEST event you should be fine.