Forum Discussion

irshad's avatar
irshad
Icon for Nimbostratus rankNimbostratus
Sep 03, 2019

User-Agent Irule to avoid APM policy

Dear Community,

 

We have scenario like when users access the url from laptops or PCs APM policy needs to take if any mobile handsets it shouldn't. We have applied the iRule but after this not able to access from laptops or PCs. Please suggest any changes in Irule.

 

But in Netscaler the below expression was working find:

 

Netscaler Policy

http.REQ.hostname.eq("test.net")) && (HTTP.REQ.HEADER("User-Agent").CONTAINS("iPhone") || HTTP.REQ.HEADER("User-Agent").CONTAINS("iPad") || HTTP.REQ.HEADER("User-Agent").CONTAINS("Android") || HTTP.REQ.HEADER("User-Agent").CONTAINS("Windows Mobile") || HTTP.REQ.HEADER("User-Agent").CONTAINS("Windows Phone") || HTTP.REQ.HEADER("User-Agent").CONTAINS("nintex-mobile") || HTTP.REQ.HEADER("User-Agent").CONTAINS("nintex-tablet"))

 

when HTTP_REQUEST {

  switch -glob [HTTP::header User-Agent] {

    "*iphone*" - 

    "*ipod*" -  

    "*android*" - 

    "*Windows Mobile*" -

    "*Windows Phone*" -

    "*nintex-mobile*" -

    "*nintex-tablet*" -

   {

    pool Test-pool

  }

 }

}

  • What do you mean with 'avoid APM policy'? If you want to disable the APM policy for some devices you can use the ACCESS::disable command. See: https://clouddocs.f5.com/api/irules/ACCESS__disable.html

    For the iRule, try this:

    switch -glob [string tolower [HTTP::header "User-Agent"]] {
        "*iphone*" - 
        "*ipod*" -  
        "*android*" - 
        "*windows mobile*" -
        "*windows phone*" -
        "*nintex-mobile*" -
        "*nintex-tablet*" {
            pool Test-pool
        }
        default {
        }
    }
  • What do you mean with 'avoid APM policy'? If you want to disable the APM policy for some devices you can use the ACCESS::disable command. See: https://clouddocs.f5.com/api/irules/ACCESS__disable.html

    For the iRule, try this:

    switch -glob [string tolower [HTTP::header "User-Agent"]] {
        "*iphone*" - 
        "*ipod*" -  
        "*android*" - 
        "*windows mobile*" -
        "*windows phone*" -
        "*nintex-mobile*" -
        "*nintex-tablet*" {
            pool Test-pool
        }
        default {
        }
    }
    • irshad's avatar
      irshad
      Icon for Nimbostratus rankNimbostratus

      Hi Niels,

       

      Yes to avoid APM Policy, Using below irule and it is working.

       

      when HTTP_REQUEST {

           switch -glob [string tolower [HTTP::header User-Agent]] {

          "*iphone*" - 

          "*ipod*" -  

          "*android*" - 

          "*Windows Mobile*" -

          "*Windows Phone*" -

          "*nintex-mobile*" -

          "*nintex-tablet*" {

            log local0. "APM disabled."

            ACCESS::disable

            } default { 

            ACCESS::enable } 

           }

      }

      • Nice! Make sure you change 'Windows Mobile' and 'Windows Phone' to all lowercase to match the [string tolower [HTTP::header User-Agent]] statement.