Forum Discussion
using irule and datagroup to allow/restric access to http::path
I want to use an irule to select the pool based on http::path; and i also need to restrict access to certain parts (namely /em and /console ) with an IP-allowed datagroup. The irule appears to not work & i dont know what is going wrong. If i remove the 'datagroup' part it works; but everyone is allowed access. i need to restrict that to /em and /console.
In the OBIEE-Allowed_access is 1 datagroup (network) witth in in 192.168.0.0/16 & 1 dedicated test ip.
when HTTP_REQUEST { if { [HTTP::path] equals "/" } { HTTP::redirect "/analytics/" } if { [HTTP::path] starts_with "/analytics" } { log local0. " .. starts_with /analytics" pool BI02-9003-Pool } if { not ([class match [IP::client_addr] equals OBIEE_Allowed_Access]) } { log local0. "[IP::client_addr] is not permitted to site /EM or /CONSOLE" drop } if { [HTTP::path] starts_with "/em" } { log local0. " .. starts_with /em" pool BI02-9001-Pool } if { [HTTP::path] starts_with "/console" } { log local0. " .. starts_with /console" pool BI02-9001-Pool } }
Thanks!
1 Reply
Hi MegaNoob,
you may try the iRule below...
when HTTP_REQUEST { set low_path [string tolower [HTTP::path]] if { $low_path equals "/" } then { HTTP::redirect "/analytics/" } elseif { $low_path starts_with "/analytics" } then { log local0. " .. starts_with /analytics" pool BI02-9003-Pool } elseif { ( $low_path starts_with "/em" ) or ( $low_path starts_with "/console" ) } then { if { [class match [IP::client_addr] equals OBIEE_Allowed_Access] } then { Allow trusted clients log local0. "[IP::client_addr] is permitted to site /EM or /CONSOLE" pool BI02-9001-Pool } else { Drop untrusted clients log local0. "[IP::client_addr] is not permitted to site /EM or /CONSOLE" drop } } else { You may add a drop or HTTP::respond here if you need to deny access outside of /em, /console or /analytics } }Note: The iRule uses a
syntax to make the rule-set case-insensitiv. In addition to that the iRule now uses a[string tolower [HTTP::path]]
notation, so that the execution will stop if the requested path already matched one of your rule-sets.if...elseif...elseCheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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