Forum Discussion
Ert_27713
Nimbostratus
Jan 21, 2008Irule ACL based on URI
Can someone help me with creating a rule that can filter URI access based on IP address.
Something like
userIP1 can access /userDIR1
userIP2 can access /userDIR2
userIP3 can access /userDIR3
anyIP can access /publicDIR
default drop
Here is my stab at it, that doesn't work:
when CLIENT_ACCEPTED {
if {[matchclass [IP::remote_addr] equals $::userIP1] and [HTTP::uri] equals /userDIR1} then {
log local0.info "Allowed client to userIP1: [IP::remote_addr] requesting: [HTTP::uri]"
} elseif {
if {[matchclass [IP::remote_addr] equals $::userIP2] and [HTTP::uri] equals /userIP2} then {
log local0.info "Allowed client to userIP2: [IP::remote_addr] requesting: [HTTP::uri]"
} elseif {
if {[matchclass [IP::remote_addr] equals $::userIP3] and [HTTP::uri] equals /userIP3} then {
log local0.info "Allowed client to userIP3: [IP::remote_addr] requesting: [HTTP::uri]"
} else {
if {[HTTP::uri] equals /any}
} else {
default {
drop
log local0. "Dropped client [IP::remote_addr] requesting: [HTTP::uri]"
}
}
}
Thanks
Eric
- hoolio
Cirrostratus
I expect you'd get a parser error when trying to save that rule because the HTTP::uri command isn't valid in the CLIENT_ACCEPTED event. To access the HTTP request headers, you should use the HTTP_REQUEST event. The IP:: commands are still valid there as well, so you can just change CLIENT_ACCEPTED to HTTP_REQUEST. - Colin_Walker_12Historic F5 AccountSo what hoolio's saying is, try something like:
when HTTP_REQUEST { if {[matchclass [IP::remote_addr] equals $::userIP1] and [HTTP::uri] equals /userDIR1} { log local0.info "Allowed client to userIP1: [IP::remote_addr] requesting: [HTTP::uri]" } elseif {[matchclass [IP::remote_addr] equals $::userIP2] and [HTTP::uri] equals /userIP2} { log local0.info "Allowed client to userIP2: [IP::remote_addr] requesting: [HTTP::uri]" } elseif {[matchclass [IP::remote_addr] equals $::userIP3] and [HTTP::uri] equals /userIP3} { log local0.info "Allowed client to userIP3: [IP::remote_addr] requesting: [HTTP::uri]" } else { drop log local0. "Dropped client [IP::remote_addr] requesting: [HTTP::uri]" } }
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