Akshay_SK
Jan 16, 2020Nimbostratus
Catch an error in iRule execution
I would like some help in handling errors in an iRule. Below is the code snippet upto which I have been able to achieve, but haven't been able to get the desired results.
when HTTP_REQUEST {
#If XFF exists then change Source IP to the first IP that you find in XFF which is the origin. Check this at the very start.
if { [HTTP::header values "X-Forwarded-For"] ne "" } {
set remoteip [getfield [HTTP::header X-Forwarded-For] "," 1]
}
if { [catch {
if { [class match $remoteip equals MY_BLACKLIST_IPS] && not [class match $remoteip equals MY_PROXY_IPS] } {
# reject the request here.
log local0. "Request is rejected here."
reject
return
}
} err] } {
log local0. "Error found in the iRule process ${err}"
}
return
}
I want to log the error as well due to which the iRule encountered. The error currently is being logged as empty.