Forum Discussion
iRule HTTP::header exists
I am attempting to check if an HTTP header exists but the rule will not save due to an error in the if statement. The HTTP:header devcentral page shows an example just like what I am using. Any help would be greatly appreciated. See below.
when CLIENT_ACCEPTED {
if { [HTTP::header exists "Bonafide-Client-IP"] } {
set trueIP [HTTP::header "Bonafide-Client-IP"]
} else {
set trueIP [IP::client_addr]
}
if { [class match trueIP equals bot_list] } {
log local0. "BOT_CHECK: IP found in bot_list! Sending [IP::client_addr] to bad bot pool..."
pool corp_pool_bad_bot
}
}
3 Replies
- Kevin_Stewart
Employee
It may be a typo in the wiki page. The HTTP::header command is not valid in the CLIENT_ACCEPTED event. Use the HTTP_REQUEST event instead.
- StephanManthey
Nacreous
The iRule will run only in context of HTTP_REQUEST event. And you need to use a variable with your 'class match':
[class match $trueIP equals dg_source_snat] - Erik_27939
Nimbostratus
Thanks guys! That did it!
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