Forum Discussion

BaltoStar_12467's avatar
Sep 18, 2015

BIG-IP : irule not matching uri as expected

F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi

 

This code is logging all requests - including those with uri "/404" :

 

when HTTP_REQUEST {
  if {[HTTP::uri] != "/404"} {
    log local0. "uri = [HTTP::uri]"
  }
}

Where is my mistake ?

 

9 Replies

  • Are you trying to log the 404 error in the response packet? try using when HTTP_RESPONSE function and see if you can log 404 error.

     

    • Sriram_87174's avatar
      Sriram_87174
      Icon for Nimbostratus rankNimbostratus
      You can try using HTTP::path instead of HTTP::uri when HTTP_REQUEST { if {[HTTP::path] != "/404"} { log local0. "uri = [HTTP::uri]" } }
    • Sriram_87174's avatar
      Sriram_87174
      Icon for Nimbostratus rankNimbostratus
      I tried with both HTTP::path and HTTP::uri - It works fine. i am using v11.4.1 BIG IP appliance.
  • does the logged /404 uri match exactly /404 as per your irule or does it start with or contain /404 i.e. /404/

     

    cheers

     

  • not sure what's going on then - I'm using 11.6 VE, prehaps you can run the same commands and post your results

    ltm rule test404 {
      when HTTP_REQUEST {
        if {[HTTP::uri] != "/404"} {
          log local0. "uri = [HTTP::uri]"
        }
      }
    }
    
    [root@f5lab] config  curl http://10.12.12.145/402
    [root@f5lab] config  curl http://10.12.12.145/403
    [root@f5lab] config  curl http://10.12.12.145/404
    [root@f5lab] config  curl http://10.12.12.145/405
    
    Sep 18 16:43:00 f5lab info tmm[17994]: Rule /Common/test404 : uri = /402
    Sep 18 16:43:05 f5lab info tmm[17994]: Rule /Common/test404 : uri = /403
    Sep 18 16:43:11 f5lab info tmm[17994]: Rule /Common/test404 : uri = /405
    
  • Try using ne instead of !=. You may be having an issue with data type conversion. Using ne will ensure you are doing a string comparison. I'm not positive that is the issue, but it's an easy change to test.