Forum Discussion
Doug_104173
Nimbostratus
Jun 01, 2010Allow based on IP for uri starts_with
Hi, I am trying to come up with an iRule to only allow people to login to a certain page of our app if they originate from a single IP. Basically you can login to www.foo.com/admin if you come from 10.0.0.100. If you don't, meet the source IP request we'd like to drop the http request. I think i have it right but I unfortunately don't have a test bigip to try this on so I was hoping someone could take a look at my rule to see if it looks ok or there is a better way to do it. It does pass a syntax check.
when HTTP_REQUEST {
if {([HTTP::uri] starts_with "/admin" ) and ([IP::addr [IP::client_addr] equals 10.0.0.100])} {
} else {
drop
}
}
- Doug_104173
Nimbostratus
Ok, well that obviously didn't work once I tested it.when HTTP_REQUEST { if { ( [HTTP::uri] starts_with "/admin" ) and ( [IP::addr [IP::client_addr] equals 10.0.0.2] ) } { HTTP::redirect "https://foo.com/admin/index/index/" } else { HTTP::redirect "https://foo.com/login/index/login/" } }
- Michael_Yates
Nimbostratus
What you've got should do a good job.when HTTP_REQUEST { if { ([HTTP::uri] starts_with "/admin") and ([matchclass [IP::remote_addr] equals $$IPAddressDataGroup]) } { HTTP::redirect "https://foo.com/admin/index/index/" } else { HTTP::redirect "https://foo.com/login/index/login/" } }
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