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: ...
RobS
Altostratus
Jan 16, 2013Bhattman and nitass,
Thanks for the responses! As a result I have come up with the following which does seem to be working (I built a test pool out of Cisco switches with http enabled which I disable for the test):
when HTTP_REQUEST {
if { [active_members F5_LB_Switches] < 1 } {
switch -glob [string tolower [HTTP::header User-Agent]] {
"*scooter*" -
"*slurp*" -
"*msnbot*" -
"*fast-*" -
"*teoma*" -
"*googlebot*" {
HTTP::respond 503 content "" noserver
return
}
}
switch -glob [string tolower [HTTP::uri]] {
"/" { HTTP::respond 200 content [ifile get f5maint_txt] }
"/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
}
}
}
}
Using curl with the User-Agent string with the bot names does come back with a 503 like I want. If you have another minute, please let me know if you see any major flaws.
Thanks!
Rob
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