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

Blogger11_11505's avatar
Blogger11_11505
Icon for Nimbostratus rankNimbostratus
Aug 22, 2013

How to Block all traffic that doesn't start with certain string question

Hello,

I'm trying to block all traffic that doesn't start with a certain string. I've wrote the iRule below but it's not working. Does anyone have any hints or tips? My iRule is probably more complicated than it needs to be but I feel like it should work.


when HTTP_REQUEST {
  if { [HTTP::path  ] starts_with "/CHD"} {
    pool 
  }
  elseif {not [HTTP::path  ] starts_with "/CHD"}{
    HTTP::respond 403 content {Blocked!}
  }
}

4 Replies

  • Wow, I have no idea why the forum messed up the formatting on that. Here is my iRule:

     

    when HTTP_REQUEST { if { [HTTP::path ] starts_with "/CHD"} { pool pool_soa_wservicetst_80 } elseif {not [HTTP::path ] starts_with "/CHD"}{ HTTP::respond 403 content {Blocked!} } }

     

  •     Code when HTTP_REQUEST {
      if { [HTTP::path  ] starts_with "/CHD"} {
        pool pool_soa_wservicetst_80
      }
      elseif {not [HTTP::path  ] starts_with "/CHD"}{
        HTTP::respond 403 content {Blocked!}
      }
    }
  • does the case matter on that path? what if it comes in /chd, is that still ok?

    This should work (assumes pool pool_soa_wservicetst_80 is the default pool):

    when HTTP_REQUEST {
      if { not([string tolower [HTTP::path]] starts_with "/chd") } { HTTP::respond 403 content "Blocked!" }
    }