Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

multiple uri and url filtering

Hi All

I have a requirement to craft an iRule to allow only specific uri's and url's for specific virtual server with two particular hosts

I have crafted the below irule, but unfortunately it's not correctly compiling

when HTTP_REQUEST { if { not ([HTTP::host] equals "auto.abc.com " || [HTTP::host] equals "auto-alb1.abc.com")} { switch [HTTP::uri]{ "/auto/auto.svc" "/auto/auto.svc/security" "/auto/auto.xml" then { drop } } } }

any thoughts on how to get it worked ?

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

this one may compile succesfully

when HTTP_REQUEST { 
  if { not ([HTTP::host] equals "auto.abc.com " || [HTTP::host] equals "auto-alb1.abc.com")} { 
    switch [HTTP::uri]{ 
      "/auto/auto.svc" - "/auto/auto.svc/security" - "/auto/auto.xml" { drop } 
    } 
  }
}
0
Comments on this Answer
Comment made 2 months ago by Thanushka.Wijethunge 57

I have applied the iRule and getting below error message

Image Text

0
Comment made 2 months ago by Thanushka.Wijethunge 57

Below iRule compiled, but not sure whether it's working

when HTTP_REQUEST { if { not ([HTTP::host] equals "auto.abc.com" || [HTTP::host] equals "auto-alb1.abc.com") || (([string tolower [HTTP::uri]] starts_with "/auto/auto.svc") || ([string tolower [HTTP::uri]] starts_with "/auto/auto.svc/security") || ([string tolower [HTTP::uri]] starts_with "/auto/auto.xml")) } then { drop } }

0
Comment made 2 months ago by Thanushka.Wijethunge 57

Above doesn't work, any idea how to accomplish ?

0
Comment made 2 months ago by oscarnet 220

HI

try it!

when HTTP_REQUEST { 
if { not ([HTTP::host] equals "auto.abc.com" || [HTTP::host] equals "auto-alb1.abc.com") } { 
    switch -glob [HTTP::uri] { 
        "/auto/auto.svc" -
        "/auto/auto.svc/security" -
        "/auto/auto.xml" {
        drop 
        } 
    } 
}
}

Have a Good day!

0