Forum Discussion
RobS
Altostratus
Jun 11, 2008ACL for sub-website?
I'm pretty weak with iRules so I was wondering if anyone has an idea on how to accomplish the following:
I need an iRule that checks for users destined for a subsite on our URL and then filtering through an ACL. I think this would be accomplished by first using:
when HTTP_REQUEST {
switch -regexp [string tolower [HTTP::uri] ] {
^/xxx
After determining users are destined to this subsite I need to apply the ACL and only allow those I specified in a Data Group List. I saw the sample for the ACL, but I having difficulty figuring out how I would tie the whole thing together. Any help greatly appreciated.
Thanks!
5 Replies
- The_Bhattman
Nimbostratus
I haven't tested this but I think it might the logic you are looking for.class subsite { "/foo" "/foobar" "/feefifoo" } class allow { "192.168.1.1" "192.168.1.3" "192.168.1.4" } when HTTP_REQUEST { if { not ([matchclass [IP::client_addr] equals $::allow] && [matchclass [string tolower [HTTP::uri]] starts_with $::subsite]) } { } else { reject } }
orclass allow { "192.168.1.1" "192.168.1.3" "192.168.1.4" } when HTTP_REQUEST { switch -regex [HTTP::uri] { "^XXX" { if { not ([matchclass [IP::client_addr] equals $::allow]) } } else { reject } } }
hope this helps
CB - Deb_Allen_18Historic F5 Accountyou'd want to be sure the class you create is of type "Address" for the IP::addr comparison to work as expected.
The resulting class would look more like this:class myIPs { host 10.10.1.1 network 192.168.1.1 255.255.255.0 }
There are at least a couple of good ACL examples in the codeshare:
Click here
Click here
/deb - Deb_Allen_18Historic F5 Accountoh, and cmbhatt's first example for the additional URI comparison is preferred -- avoid regex wherever possible.
/deb - RobS
Altostratus
CB & Deb,
Thanks for your help on this one. We got it working just the way we want by slightly altering the example you provided:
class subsite {
"/foo"
"/foobar"
"/feefifoo"
}
class allow {
"192.168.1.1"
"192.168.1.3"
"192.168.1.4"
}
when HTTP_REQUEST {
if { not [matchclass [IP::client_addr] equals $:: allow] && [matchclass [string tolower [HTTP::uri]] contains $:: subsite] } {
discard
} else {
}
}
Thanks,
Rob - hoolio
Cirrostratus
As Deb suggested before, you'd actually want to define the class as a type of 'address' to avoid doing a string comparison against the client IP address. This also allows you to define networks instead of individual hosts.
The bigip.conf entry should look like:class myIPs { host 10.10.1.1 network 192.168.1.1 255.255.255.0 }
And make sure you don't have a space in the class references. They should be $::allow and $::subsite.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
