Forum Discussion

farnsworth_7311's avatar
farnsworth_7311
Icon for Nimbostratus rankNimbostratus
Dec 18, 2007

Blocking a URL except from specific IP addresses

We would like to block access to a specific URL for a web application except if it is coming in from our VPN (known IP address ranges) or from our internal network. ie /admin but allow /user. How should the irule be written
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    To clarify:

    If a user makes a request for www.domain.com/admin, deny them unless they are on your internal network (we'll say 10.0.0.1/24).

    Correct?

    If so, then you'd want something like:

    
    when HTTP_REQUEST {
      if { [HTTP::uri] starts_with "/admin" } {
        if {[IP::client_addr] starts_with "10.0.0" } {
          pool http_pool
        } else {
          reject
        }
      }
    }

    This is, of course, an extremely simple example. If you wanted to add a bit more intelligence/flair, you could use a network range when doing the comparison, send a custom HTTP response, etc.

    HTH,

    Colin