You could use an iRule like this to detect if a prior iRule has changed the pool from the virtual server's default pool or issued an HTTP redirect (using HTTP::redirect) or response (using HTTP::respond):
when CLIENT_ACCEPTED priority 1 {
Ensure this event runs first to save the VS's default pool name
set default_pool [LB::server pool]
}
when HTTP_REQUEST priority 999 {
Ensure this event runs after any iRules which should take precedence over this one
Check if the currently selected pool has changed or an HTTP redirect/response has been triggered already.
if { ([LB::server pool] ne $default_pool) or [catch {HTTP::payload replace 0 0 {}}] } {
set already_responded 1
} else {
set already_responded 0
}
if {$already_responded == 0}{
Do something like select a pool or redirect the client
}
}
Or if you don't care about pool changes and just want to detect a redirect/respond, you could simplify the iRule:
when HTTP_REQUEST priority 999 {
Ensure this event runs after any iRules which should take precedence over this one
Check if an HTTP redirect/response has been triggered already.
if { [catch {HTTP::payload replace 0 0 {}}] } {
set already_responded 1
} else {
set already_responded 0
}
if {$already_responded == 0}{
Do something like select a pool or redirect the client
}
}
Both examples attempt to insert nothing in the request payload. If a redirect/response has already been sent in an iRule, catch traps a runtime error and a variable is set to track it.
Aaron