Forum Discussion
Logging a redirect generated from a different iRule.
We use a consistent iRule across our VIPs to log all requests. We have more specific iRules on some VIPs to perform URI based load balancing and in some cases redirects. The problem is that when a redirect is fired from one iRule, there's no entry in the request log.
Came across this : https://devcentral.f5.com/wiki/iRules.detect_prior_http_redirect_or_respond.ashx
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
}
}
This seems promising and provides a place to detect if a redirect was fired, but experimentation to this point hasn't provided a way to pull information from that redirect. Things like was it a 301 or a 302? what location the response was, etc.
Has anyone done something like this before? If I can't do it in a single place, might have to do it in each rule, but that could be significantly more maintenance. Thanks for the help.
3 Replies
- Michael_Jenkins
Cirrostratus
You might be able to use procedures to accomplish the logging part of this. I don't know if you'd be able to set a variable and keep track of it within the procedure (if you needed to do that), but for simple logging, you could try that.
Hey cool. Thanks Michael.
- TejasPatil_3077
Nimbostratus
Hey cdougall,
Have you found solution for the problem? Can you please share your findings?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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