Forum Discussion
Glenn_32883
Nimbostratus
Jun 10, 2010irule to restrict access by ip
Hi everyone,
My irule experience is basically setting up some redirects. Now I am trying to set up a whitelist of IPs to restrict who can access a certain sub folder of our site. The rest of the site is available to the public.
I tried some of the examples I could find here and came up with this.
when HTTP_REQUEST {
if { ([HTTP::uri] starts_with "/epp") and ([matchclass [IP::remote_addr] equals $$epp-test]) } {
HTTP::redirect https://[HTTP::host][HTTP::uri]
} else {
drop }
}
I have a Data Group List called epp-test.
When I put this in place it seems to drop everything, whether I come from an IP on the list or not, and even if I am trying to access parts of my site not in "/epp"
Any suggestions would be greatly appreciated!
Glenn
- hoolio
Cirrostratus
Hi Glenn, - Michael_Yates
Nimbostratus
Actually I believe that it is your original iRule.when HTTP_REQUEST { if { ([HTTP::uri] starts_with "/epp") and !([matchclass [IP::remote_addr] equals $::epp-test]) } { drop } elseif { ([HTTP::uri] starts_with "/epp") and ([matchclass [IP::remote_addr] equals $::epp-test]) } { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } }
- Glenn_32883
Nimbostratus
Thanks for the input everyone! Just posting back what worked for me for future reference. - DaveC_53879
Nimbostratus
Where and how are you defining $::epp_test? Thanks - nitass
Employee
Where and how are you defining $::epp_test?i understand it is a data group. it is under local traffic/irules/data group list in webui. in cli, it is called class.[root@ve1023:Active] config b class epp_test list class epp_test { { host 1.1.1.1 network 20.20.20.0/24 } }
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