Forum Discussion
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!
Yep, "Starts_with" worked. Many Thanks to ekaleido and Odaah!!!
- Vijay_ECirrus
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?
- Vijay_ECirrus
From a client machine.
- ekaleidoCirrus
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.
Yep, "Starts_with" worked. Many Thanks to ekaleido and Odaah!!!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com