Forum Discussion

dabance's avatar
dabance
Icon for Altocumulus rankAltocumulus
Nov 28, 2018

filter based on "User-Agent" , irule

I want permit traffic to a VIP only if the User-Agent matches "Chrome/52.0.2743.98" Does the below irule works?. Also i want to add logging.

 

when HTTP_REQUEST { if {[HTTP::header "User-Agent"] contains "Chrome/52.0.2743.98" } { return } else { drop } }

 

1 Reply

  • Yes, that iRule should do the job although it is a little blunt. You also want to consider whether contains is good enough or you should have exact matching.

    Logging can be done locally to /var/log/ltm with the log command eg

    log local0.debug "User Agent: [HTTP::header user-agent]"
    but ideally you would do regular logging to a remote server via HSL.

    You may also want to check if the User-Agent header exists - note that HTTP headers are non case sensitive.