Forum Discussion
dubdub
Jun 15, 2011Nimbostratus
iRule to intercept traffic and then send on to original pool
Hi all,
I refuse to believe this is impossible, so I just need some advice on how to make it happen!
I am trying to create an iRule to intercept certain requests for additional pro...
dubdub
Jun 20, 2011Nimbostratus
Just to follow up... finally got this working, this is the final iRule, which is a variation on the excellent ideas suggested in http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/14001/showtab/groupforums/Default.aspx.
when RULE_INIT {
set static::debug 1
}
when CLIENT_ACCEPTED {
if { $static::debug != 0 } {
log local0. "setting addingUser to 1"
}
set addingUser 1
}
when HTTP_REQUEST {
save original request
if { $addingUser == 1 } {
if { $static::debug != 0 } {
log local0. "saving request, redirecting to WebFarm"
}
set req [HTTP::request]
inject lookup URI in place of original request
HTTP::uri "/addDWUser"
set pool to webfarm pool
pool pool_WebFarm
}
}
when HTTP_RESPONSE {
if {$addingUser == 1 } {
collect first response (from lookup server) only
if {[HTTP::header exists Content-Length] && ([HTTP::header Content-Length] < 1048576) } {
set clength [HTTP::header Content-Length]
} else {
set clength 1048576
}
if { $static::debug != 0 } {
log local0. "collecting response presumably from WebFarm, length is $clength"
}
HTTP::collect $clength
}
}
when HTTP_RESPONSE_DATA {
Get poolname from server response
Response would ideally be in the form of a pool name only.
Otherwise parse or derive the poolname here
set myPool pool_DataWarehouse
verify pool exists and has members
if { ![catch [pool $myPool]] }{
if { $static::debug != 0 } {
log local0. "retrying request"
}
pool pool_DataWarehouse
HTTP::retry $req
} else {
insert dead/non-existent pool logic here
}
re-set flag so that subsequent response to re-tried
request from real server is not processed as a lookup
if { $static::debug != 0 } {
log local0. "setting addingUser to 0"
}
set addingUser 0
}
Thanks!
Jen
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