Forum Discussion

Erik_27939's avatar
Erik_27939
Icon for Nimbostratus rankNimbostratus
Sep 25, 2013

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

  • 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.

     

  • 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]