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: ...
nitass
Employee
Jan 16, 2013e.g.
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
destination 172.28.20.14:80
ip-protocol tcp
mask 255.255.255.255
pool foo
profiles {
http { }
tcp { }
}
rules {
myrule
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vlans-disabled
}
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm pool foo
ltm pool foo {
members {
200.200.200.101:80 {
address 200.200.200.101
session monitor-enabled
state down
}
}
monitor fake
}
Controlling Bots
https://devcentral.f5.com/wiki/iRules.ControllingBots.ashx
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm rule myrule
ltm rule myrule {
when HTTP_REQUEST {
if { [active_members [LB::server pool]] < 1 } {
switch -glob [string tolower [HTTP::header User-Agent]] {
"*scooter*" -
"*slurp*" -
"*msnbot*" -
"*fast-*" -
"*teoma*" -
"*googlebot*" {
HTTP::respond 503 content "" noserver
return
}
}
switch [HTTP::path] {
"/f5.gif" { HTTP::respond 200 content [ifile get f5_gif_ifile] noserver }
default {
HTTP::respond 200 content [ifile get maint_html_ifile] noserver
}
}
}
}
}
maintenance page
[root@ve11a:Active:Changes Pending] config curl -i http://172.28.20.14
HTTP/1.0 200 OK
Connection: Keep-Alive
Content-Length: 97
This is maintenance page.
googlebot
[root@ve11a:Active:Changes Pending] config curl -i http://172.28.20.14 -H "User-Agent: googlebot"
HTTP/1.0 503 Service Unavailable
Connection: Keep-Alive
Content-Length: 0
normal page
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) modify ltm pool foo monitor none
root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm pool foo
ltm pool foo {
members {
200.200.200.101:80 {
address 200.200.200.101
}
}
}
[root@ve11a:Active:Changes Pending] config curl -i http://172.28.20.14
HTTP/1.1 200 OK
Date: Wed, 16 Jan 2013 07:39:16 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Sat, 27 Oct 2012 03:22:35 GMT
ETag: "4183f3-59-f28f94c0"
Accept-Ranges: bytes
Content-Length: 89
Content-Type: text/html; charset=UTF-8
This is 101 host.
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
