Forum Discussion
ramki_75145
Nimbostratus
Dec 19, 2007maintenance 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.
- Colin_Walker_12Historic F5 AccountHere'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 } } }
- ramki_75145
Nimbostratus
Thank you Colin, - JRahm
Admin
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.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects