Forum Discussion

JNeilson_117973's avatar
JNeilson_117973
Icon for Nimbostratus rankNimbostratus
Jan 19, 2015

iRule to allow one of two URIs block all others

I am trying to create an iRule that will allow a URL that contains: /!portal/240100000001001 or /!portal/240100000001002 and blocks all other variations.

 

I have tried using a data group with iRule and can only manage to get it to block all URLs. Can anyone help? For the data group I have tried both the full URL and /!portal/240100000001001

 

class MCEP_allowed_URIs { "/system/templates/selfservice/sunburst/!portal/240100000001001" "/system/templates/selfservice/sunburst/!portal/240100000001002" }

 

when HTTP_REQUEST { if { [ class match [string tolower [HTTP::uri]] contains MCEP_allowed_URIs ] } { Stop processing the iRule for this event here return else { drop } } }

 

3 Replies

  • I wouldn't both with a data group if there are only two URIs involved. I'd use something like this. You can remove the logging once it tests out OK;

    when HTTP_REQUEST {
      switch [string tolower [HTTP::uri]] { 
        "/system/templates/selfservice/sunburst/!portal/240100000001001" {
          Stop processing the iRule for this event here
          log local0. "Match on 240100000001001"
          return
        }
        "/system/templates/selfservice/sunburst/!portal/240100000001002" {
          Stop processing the iRule for this event here
          log local0. "Match on 240100000001002"
          return
        }
        "default" {
        drop
        }
      }
    }
    

    If you don't see a match, perhaps its to do with the

    !
    ?