Forum Discussion
SighclopsII_189
Nimbostratus
Feb 25, 2015iRule to allow access to a uri only from a specific source subnet
I am looking to create an iRule that will allow access to uri's containing specifics when coming from an approved subnet but dropping requests to those uri's when coming from all other subnets.
...
Michael_Jenkins
Cirrostratus
Feb 25, 2015This should work based on your iRule (just changed the
|| to && to make it and)
when HTTP_REQUEST {
if { ([HTTP::uri] contains "/something/bla/test/testing") && ([IP::addr [IP::client_addr] equals 10.1.1.0/24]) } {
pool My_Web_Pool
} else {
HTTP::respond 200 content { Sorry Page Sorry, this Page is restricted. }
}
}
Or try this updated one
when HTTP_REQUEST {
The switch statement is good for conditionals and easy to manage.
The '-glob' parameter marks the switch to allow wildcards (the "*")
switch -glob -- [string tolower [HTTP::uri]] {
"*/something/test/testing*" {
if { [IP::addr [IP::client_addr] equals 10.1.1.0/24] } {
Process the traffic
pool POOL_NAME
} else {
HTTP::respond 200 content { Sorry Page Sorry, this Page is restricted. }
}
}
}
}
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