Forum Discussion

Rajesh_Balla's avatar
Rajesh_Balla
Icon for Nimbostratus rankNimbostratus
Aug 17, 2016

Need irule to block the traffic based on specific http parameters.

Hi

 

Need help in creating an irule for a VIP block android user agents. these users are causing load. need to block based on site id parameter and user agent. To be specific a useragent with specific site ID has to be blocked.

 

4 Replies

  • there are two ways to do this. one is to use datagroups in the irule and use class match statements. in the datagroups specify the strings u want to match on. below is the straigh irule reference u can either use a pool as an action or simply add a reject statement then and default for all other actions

    when HTTP_REQUEST {
    
       if { ( [string tolower  [HTTP::uri]] contains "/testconnect/")  && ( [string tolower [HTTP::header User-Agent]] starts_with "java/" ) }  {
         pool _something 
        } else {
            HTTP::respond 200 content "not allowed..."
            reject
        }
    }
    
  • Hi Rajesh,

     

    can you provide an example request? I mean where is the site ID located? Is this part of the URI, a query parameter, a header or cookie value? And what's the exact name of it?

     

    Ciao Stefan :)

     

  • Hi Rajesh,

     

    you still forgot to mention the exact name of the header or query parameter or section in the URI, where to look for.

     

    Ciao Stefan :)

     

  • Hi,

    are you sure "Site ID" is the header name?

    I never saw a header name with space...

    As requested Stefan, can you provide an example of the request? because, you are talking about parameter, header name... with is not the same.

    when requesting

    http://www.company.com/path?q=test&lang=en
    the request is:

    GET /path?q=test&lang=en HTTP/1.1
    Host: www.company.com
    user-agent: Mozilla...
    

    in this request:

    • URI is /path?q=test&lang=en
    • path is /path
    • parameters:
      • q with value test
      • lang with value en
    • headers:

    So, what do you want to filter?