For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

sbrudolf1_14757's avatar
sbrudolf1_14757
Icon for Nimbostratus rankNimbostratus
May 29, 2014

Trouble with APM Irule

I am new to writing iRules and the switch function.. I am having trouble using the switch and a not statement to check if a cookie exists and then run the switch on that condition.. I know i am using the wrong syntax, i am trying to have an irule that checks if a cookie is present, then determines if a certian URL is accessed. If a URL is accessed and there is no cookie present, then APM would disable. Any help would be appreciated.

when HTTP_REQUEST {
if { 
    not ( [HTTP::cookie exists MRHSession] ) {
        switch -glob [string tolower [HTTP::path]]{ 
            "/uri1" -
            "/uri2" { 
                ACCESS::disable
            }
        }
    } else {
    ACCESS::enable
    return
    } 
}

}

3 Replies

  • What behavior are you seeing from the iRule? I would think something like this should work:

    when HTTP_REQUEST {
     if { ! ( [HTTP::cookie exists MRHSession] ) } {
        switch -glob [string tolower [HTTP::path]]{ 
                "/uri1*" -
                "/uri2*" { 
                    ACCESS::disable
                }
            }
        } 
     else {
        ACCESS::enable
        return
        }
    }
    
  • I get error: [wrong args] when trying to save that, i have the same problems when trying to use a datagroup list.

     

    I want APM to be disabled if a certain URL is accessed but only if an APM session has not already been established... I am debating on just writing something with a bunch of if statements.

     

  • It appears to be something about the formatting of your switch statement. I got this one to load:

    when HTTP_REQUEST {
     if { ! [HTTP::cookie exists "MRHSession"] } {
        switch -glob [string tolower [HTTP::path]] {
                "/uri1*" -
                "/uri2*" { 
                    ACCESS::disable
                }
            }
        } else {
        ACCESS::enable
        return
        }
    }