cancel
Showing results for 
Search instead for 
Did you mean: 

Filter to allow certain URL/URI

Tny81
Nimbostratus
Nimbostratus

Hello,

 

I have a VIP with multiple DNS alias record tied to it. I’d like to create an irule to allow only certain traffic that matches both host and path. Any other traffic will be rejected.

 

Allow:

abc.com/123/456/

abc.com/cat/dog/

xyz.com/123/456/

xyz.com/cat/dog/

 

Everything else gets drop.

 

I have one written without the host url and hoping the uri would be sufficient but seems like something isn't like it and the page overall doesn't work.

 

when HTTP_REQUEST 

{

  if {!([HTTP::uri] eq "/123/456/") and ([HTTP::uri] eq "/cat/dog/")}

  {

    reject

  }

}

 

thank in advance.

1 ACCEPTED SOLUTION

Samir
Nacreous
Nacreous

you can write iRule something below.

 

when HTTP_REQUEST { if { ([HTTP::host] equals "abc.com" or [HTTP::host] equals "xyz.com") } { if { [HTTP::uri] starts_with "/123/456/" || [HTTP::uri] starts_with "/cat/dog/" } { pool poo_A } else { reject } } }

 OR

 

when HTTP_REQUEST { if { !([HTTP::host] equals "abc.com" or [HTTP::host] equals "xyz.com") && !([HTTP::uri] starts_with "/123/456/" || [HTTP::uri] starts_with "/cat/dog/") } { reject } }

 

View solution in original post

2 REPLIES 2

Samir
Nacreous
Nacreous

you can write iRule something below.

 

when HTTP_REQUEST { if { ([HTTP::host] equals "abc.com" or [HTTP::host] equals "xyz.com") } { if { [HTTP::uri] starts_with "/123/456/" || [HTTP::uri] starts_with "/cat/dog/" } { pool poo_A } else { reject } } }

 OR

 

when HTTP_REQUEST { if { !([HTTP::host] equals "abc.com" or [HTTP::host] equals "xyz.com") && !([HTTP::uri] starts_with "/123/456/" || [HTTP::uri] starts_with "/cat/dog/") } { reject } }

 

Thank you Samir. I like the second option of yours and it seems to work.