Forum Discussion
Peter__Draper_7
Nimbostratus
Jan 27, 2005Logging requested URI on a 404 redirect rule
I am starting to use iRules on 9.0.3 and am redirecting to a static IP of a virtual server when a 404 is received. I am logging the fact that a 404 has ben seen but would like to add in the requested url/uri to the log statement so I can then know what to look at for the missing location on the suspect server.
Any assistance appreciated.
7 Replies
- drteeth_127330Historic F5 AccountYou need to save the URI in a variable in HTTP_REQUEST and then log it using the log command in HTTP_RESPONSE. Hope this helps...
- Peter__Draper_7
Nimbostratus
Thanks for the tip. How to I save in the HTTP_REQUEST and then Reference the saved information in the log section. - Peter__Draper_7
Nimbostratus
Just sorted it. Thanks - was not aware you gcould do a set to a variable the call on that variable later. - Peter__Draper_7
Nimbostratus
For info the very basic rule iswhen HTTP_REQUEST { set log_uri [HTTP::uri] } when HTTP_RESPONSE { set debug "1" if {[HTTP::status] equals "404"} { HTTP::redirect "http://10.10.8.106" if $debug {log local0. "404 error $log_uri -redirected to 10.10.8.106"} } }
- Peter_Reilly
Nimbostratus
I'm trying to do some similar logging on HTTP status, but when I use this syntax, the variable ($log_uri here) is not showing up in the log message as the content of the variable but rather as a literal string. I've tried bracketing it, closing the quotes, etc but nothing works...everything I put after the {log local0. statement is just printed literally in the log. Any ideas? - Peter__Draper_7
Nimbostratus
Not sure but if you have $log_uri here it wont like the space. - unRuleY_95363Historic F5 AccountI might suggest you try removing the debug cruft and just try this:
when HTTP_REQUEST { set log_uri [HTTP::uri] } when HTTP_RESPONSE { if { [HTTP::status] eq "404" } { HTTP::redirect "http:://10.10.10.1" log "404 error $log_uri - redirected to 10.10.8.106" } }
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