Forum Discussion
RobS
Altostratus
Jan 15, 2013Combining iRules for maintenance page with 503 code
I don't have to do iRules too often so I'm not sure if this is possible combined into one iRule, doable via two, or not possible at all. I created an iRule for my maintenace page and it works well: ...
The_Bhattman
Nimbostratus
Jan 16, 2013Hi Rob,
I think I can assist on a portion of this.
Recall the portion of the code you posted
{ [active_members [LB::server pool]] < 1 }
This should change to
{ [active_members pool] < 1] } were "pool" is your pool name
You can find references to it on the irule code wiki (https://devcentral.f5.com/wiki/iRules.active_members.ashx)
Also consider using the switch command
For example you could re-write you code to the following using the switch statement which is more efficient then IF-ELSEIF-ELSE statement
when HTTP_REQUEST {
if { [active_members pool ] < 1] } {
log local0. "Server Pool: [LB::server pool]"
HTTP::respond 200 content [ifile get f5maint_txt]
} else {
switch -glob [string tolower[HTTP::uri]] {
"/favicon.ico" { HTTP::respond 200 content [ifile get favicon_ico] }
"/reset.css" { HTTP::respond 200 content [ifile get reset_css] }
"/style_main.css" { HTTP::respond 200 content [ifile get style_main_css] }
"/jquery.js" { HTTP::respond 200 content [ifile get jquery_js] }
"/jquery.jfeed.pack.js" { HTTP::respond 200 content [ifile get jquery.jfeed.pack_js] }
"/head.js" { HTTP::respond 200 content [ifile get head_js] }
"/search.js" { HTTP::respond 200 content [ifile get search_js] }
"/image_topbarleft.jpg" { HTTP::respond 200 content [ifile get image_topbarleft_jpg] }
"/image_topbarright.jpg" { HTTP::respond 200 content [ifile get image_topbarright_jpg] }
"/image_navtop.jpg" { HTTP::respond 200 content [ifile get image_navtop_jpg] }
"/logo_main.png" { HTTP::respond 200 content [ifile get logo_main_png] }
"/image_contactbkg.png" { HTTP::respond 200 content [ifile get image_contactbkg_png] }
default { discard }
}
}
}
I hope this helps
Bhattman
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
