Forum Discussion
jondyke_46152
Nimbostratus
Jun 26, 2008Access Control Based On IP for specific URL
I am pretty new to irules so any help here would be appeciated. The irule below is the deafult irule for Access control based on IP from the codeshare area. Is it possible to alter this so that it controls access for a specific URL under the virtual server rather than the whole virtual server? ie. http://www.joeblogs.com/restricted/
when RULE_INIT {
v1.0 - basic ACL.
October, 2007
Tested on BigIP version 9.4.
Purpose:
Bind this rule to a network virtual server to simply allow or disallow traffic based on source IP.
This rule expects a datagroup named trustedAddresses that lists the addresses you wish to allow.
By default, traffic will be dropped.
}
when CLIENT_ACCEPTED {
if { [matchclass [IP::client_addr] equals $::trustedAddresses] }{
Uncomment the line below to turn on logging.
log local0. "Valid client IP: [IP::client_addr] - forwarding traffic"
forward
} else {
Uncomment the line below to turn on logging.
log local0. "Invalid client IP: [IP::client_addr] - discarding"
discard
}
}
- Andy_Herrman_22
Nimbostratus
You could create another class that contains the URLs that you want to control access to, and then have the IF check the HTTP::uri against that class (similar to the check of the client addr against the trusted addresses) first. If that matches then check the client addr against the trusted list. - jondyke_46152
Nimbostratus
Forgive my ignorance here but I am an irule virgin - would it look something like this? - jondyke_46152
Nimbostratus
Thanks - jondyke_46152
Nimbostratus
Ok - i tried the rule above and created an address datagroup and string datagroup with the securepath info. Seems to scre up my site.... are we missing the foward bit of the rule? - Andy_Herrman_22
Nimbostratus
I don't believe the 'forward' command is necessary. If you don't reject it then the F5 should process it normally. - jondyke_46152
Nimbostratus
When I tried the irule that you have written above it seems to break my site (no page displayed) at the default level which is a bit odd. - Andy_Herrman_22
Nimbostratus
Can you try using this iRule and do a couple tests, then post the log messages you get? I added some logging and put the 'forward' command in, just in case I was wrong and it is needed.when HTTP_REQUEST { if { ( [matchclass [HTTP::uri] starts_with $::securePaths] ) and ! ( [matchclass [IP::client_addr] equals $::trustedAddresses] ) } { log local0. "Untrusted IP ([IP::client_addr]) attempting to access secure path ([HTTP::uri])" discard } else { log local0. "Allowing connection from [IP::client_addr] to [HTTP::uri]" forward } }
- Andy_Herrman_22
Nimbostratus
Oh, and a quick suggestion. When posting your iRule code, use a code block to help keep the formatting. - jondyke_46152
Nimbostratus
The following message is in the log:- - Andy_Herrman_22
Nimbostratus
Sounds like the datagroup/class for the secure paths isn't defined. Does that error happen when using your own iRule code?
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