Forum Discussion
JCMATTOS_41723
Nimbostratus
Jul 09, 2009Restrict access to certain url's by sourceIP?
Hello Forum,
We are trying to utilize some irules to allow only certain users to only access specific url's? Essentially, user A, B, C are trying to access the same virtual server IP, but have different url subdirectories which we would like to restrict access to. Is it possible to have an irule that can look at the source IP and restrict access to only certain url's and deny the rest? Also, typically what kind of performance degradation can we expect to see with this implemented on a 8400 w/9.4.7?
User A => /www.abccompany.com/folderA
User B => /www.abccompany.com/folderB
User C => /www.abccompany.com/folderC
Default => Deny all
- hoolio
Cirrostratus
Hi JC,when HTTP_REQUEST { Check the requested URI switch -glob [string tolower [HTTP::path]] { "/folderA*" { Reset the request if if the source IP is not allowed if {not ([matchclass [IP::client_addr] equals $::users_A_class])}{ reject } "/folderB*" { Reset the request if the source IP is not allowed if {not ([matchclass [IP::client_addr] equals $::users_B_class])}{ reject } "/folderC*" { Reset the request if the source IP is not allowed if {not ([matchclass [IP::client_addr] equals $::users_C_class])}{ reject } default { Reset the request reject } } }
- JCMATTOS_41723
Nimbostratus
Very Cool...Thx Hoolio! Question, would there be any peformance difference in using the datagroups vs the other? Also, do you have a sample of the datagroup setup as well? - hoolio
Cirrostratus
If you had a single subnet for each group of users, it would probably be about the same to use IP::addr in the iRule versus matchclass against a datagroup. If you have more than one subnet, I expect matchclass to be faster.class hosts_subnets_class { host 1.1.1.1 network 2.0.0.0/8 }
- JCMATTOS_41723
Nimbostratus
I tried applying the irule to the VIP and it does not appear to be working? It just times out. Any ideas? - hoolio
Cirrostratus
If you want to test a single IP address/subnet, you can use IP::addr (Click here). If you want to compare the client IP to a group of IP addresses and subnets, you can create them in a datagroup (aka class) and then use matchclass:class users_A_class { host 1.1.1.1 network 2.0.0.0/8 }
if {not ([matchclass [IP::client_addr] equals $::users_A_class])}{
- JCMATTOS_41723
Nimbostratus
Thx Aaron, I created a datagroup called users_A_class thru the GUI and still no luck? Am I missing something?
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