Forum Discussion
pgsmith_120398
Altostratus
Jul 30, 2014Access control to URI based on IP using datagroups
I am attempting to perform access control to a specific URI based on IP address. We would like to permit all internal traffic to anything on the host but would like to restrict a vendors public IP ad...
pgsmith_120398
Altostratus
Jul 30, 2014i have written this and it appears to be working. Ill test with a vendor sometime and update its success.
when HTTP_REQUEST {
Check if client IP address matches the internal IP ranges, if so do nothing
if { [class match [IP::client_addr] equals internal-access-dg]}{
If the client IP is not in an internal IP range, check to see if the URI being accessed is secured.
} elseif { [class match [string tolower [HTTP::uri]] starts_with external-access-dg]} {
if the URI being accessed is secured set the variable hostvar to the value that associated with the URI name
set hostvar [class match -value [string tolower [HTTP::uri]] starts_with external-access-dg]
If the client IP matches the value associated with the URI name do nothing
if { [IP::client_addr] eq $hostvar} {
If the URI is protected and traffic is coming from an un-trusted IP reject the traffic
} else {
reject
}
}
}
Any opinions on this or re-workings would be welcome!
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