Forum Discussion

bmohanak_276891's avatar
Oct 24, 2016

Help with an iRule to allow based on two URIs

Dear Friends,

 

I need help with an iRule to allow access to a Pool based on two URIs and send a 403 Access Denied otherwise

 

So Initially I had this for one URI's but the application owner wanted two URIs I need help adding the Second URI to the iRule to allow access to the Pool otherwise send an Denied Message

 

URI's /JSSResource/abc/xyz/123 /healthcheck.html

 

The statement below sets the variable name of uri and the value string to lower case

set uri [HTTP::uri]

 

The statement below calls the variable uri and matches on conditions starts with and not equal to

if { $uri starts_with "/JSSResource/" and $uri ne "/JSSResource/"}{ pool p-casper-stage log local0. p-casper-stage } else { HTTP::respond 403 content [format "Access Denied"] } }

 

Thanks for the Help!

 

  • Try something like this after replacing the URI, pool and 403 response as required:

    when HTTP_REQUEST {
    if { ([string tolower[HTTP::uri]] eq "/abcd") or ([string tolower[HTTP::uri]] eq "/xyz") } {
    pool POOL_URI
    } else {
    HTTP::respond 403 content {403 Unauthorized}
    }
    }
    
  • the string is case-sensitive; I am getting the same response. Where would I run the CURL from?

     

  • You don't want "eq" you want "starts_with" I would imagine. Because otherwise it will return a 403 for basically everything unless your pages always render as just /jssresource or /healthcheck, which is highly unlikely.