Im new to F5 ASM so I apologize for my ignorance in advance. Is it possible to create an IRule to allow access to a webpage based on IP adresses and\ or LDAP group?
I see this as an example but not sure how to add multiple IP addresses and I dont want a redirect. Any help is appreciated.
It’s definitely possible. In that example, you’re using a data group. You can add addresses to a data group from the config utility through Local Traffic Manager > iRules > Data Groups.
Are you trying to limit access to a specific page, or a directory?
As far as blocking by IP goes, I’ve seen most people do so via LTM iRules…I’ll see whether there’s an option in ASM but don’t recall seeing one. Any reason you’re trying to avoid using LTM?
I don’t think current versions of ASM allow you to restrict access by client IP, subnet or GeoIP region, etc. I’m pretty sure there is at least one request for enhancement related to this type of functionality. You could open a case with F5 Support and have your request added to the existing RFE(s).
In the meantime, you could try a few approaches:
Create an address type datagroup containing the allowed subnets/hosts and use an iRule to check for requests to /admin that aren’t from an allowed IP. Rewrite the URI to something that will always get blocked in the ASM policy like /illegal_client_request_to_admin.exe (assuming you don’t have .exe or wildcard filetypes allowed in your policy).
Use a separate VS which goes to a separate ASM policy that allows /admin URI access (or no policy if you trust the app administrators). Restrict access to the VS using an iRule and the same address type datagroup as you would for option one. Then block all access to /admin on your main ASM policy using an attack signature.
Note that I like the second option better as ASM can normalize URI encoding attacks much better than we can with an iRule. This is particularly relevant if the web app is IIS based:
No its not using IIS…but after thinking about it - why not just use the LTM as you suggested…
I have this so far but have a question: Can I add multiple URL’s to check in this irule e.g. in BOLD I have adstructure/ i want to add other sites that have a login.jsp or login\password locations…
Yes, you can absolutely check as many URLs as you want. Can you elaborate on everything you’d like to check, and if there’s a match, what you’d like to do with the request?
Sorry for the delay…basically i need to redirect certain externally accessible sites to internal network only. And if you are not part of the IP adress redirect you to home page. This needs to be done at F5 level… So question is how do I add multiple sites to check???
This is what I was thinking of for your second scenario of an IP and multiple URI checks:
when CLIENT_ACCEPTED {
Look up client IP once per TCP connection
if { [matchclass [IP::client_addr] equals IPAddressDataGroup] }{
set matched_ip 1
} else {
set matched_ip 0
}
}
when HTTP_REQUEST {
If we had a match on the client IP, check the requested URI with wildcards
if {$matched_ip==1}{
switch -glob [HTTP::uri] {
"/adstructure*" -
"/CiteCode*" -
"/jsp/funsite*" {
IP and URI check were both true, so redirect client to custom URL
HTTP::redirect "https://www.xxx.com/adstructure/xxx/login.jsp/index/index/"
Exit this event in this iRule
return
}
}
}
If we haven't exited this event already, send a default redirect
HTTP::redirect "https://www.xxx.com/"
}