Forum Discussion
Need help to whitelist URI's
Above iRule is correct, You can remove the statement which is creating issue.
If i will be at you place then can try negative scenario and short irule for fun. You can try to use URI_DB class to add and remove the URI.
when HTTP_REQUEST {
if { !([class match [IP::client_addr] equals internal_subnets]) && ([class match [HTTP::uri] starts_with URI_DB) } {
HTTP::redirect "http://app.com/sorry.html"
}
else {
pool app_80_pool
}
}Add the all uri in URI_DB
"/sorry.html"
"/foo/combined.js*"
"/foo/css/*"
"/foo/desktopreset"
Please tune iRule per requirements.
Thanks
- k20Dec 05, 2020
Nimbostratus
I really appreciate your suggestion. If I understand your iRule correctly, our external users will be having trouble getting to those specific URI's inside the URI_DB, which is not what I want. Let me try to explain my end game here.
- There will be no restrictions to access the app for internal users whatsoever. We use source IP addresses to identify them.
- External users can only have access to a small subset of the app with some restrictions. They will be allowed to access only the URI's defined under the "switch -glob" inside the iRule (i.e. those /foo/....URI's you see in the original post) and they are also allowed access the main page "app.com"
- Finally, if the external users try to access stuff that are not allowed, we want to send them to the sorry.html page.
This is essentially like if you're inside my house, you can use whatever stuff you want. If you're outside, you can only use my bucket and shovel. If you try to borrow something else, I'm sorry. :)
I couldn't get the last condition to work.
- k20Dec 05, 2020
Nimbostratus
Hey @Samir I think you have a good point. Looks like I misread your iRule. It seems to match my goal. Let me try that and will let you know how it goes. Wish me luck.
- k20Dec 05, 2020
Nimbostratus
Just tried it and no luck. If I go to the home page app.com, it redirects me to the sorry.html. By the way, your script is missing the square bracket at the end of the URI_DB. It seems like an easy one. Oh boy, I couldn't get it to work.
.
- k20Dec 05, 2020
Nimbostratus
I have reversed the logic back to the original but now using datagroup instead of the "switch -glob" meaning,
when HTTP_REQUEST {
if { [class match [IP::client_addr] equals internal_subnets] || [class match [HTTP::uri] starts_with URI_DB] || [HTTP::host] equals "app.com"} {
pool app_80_pool
}
else {
HTTP::redirect "http://app.com/sorry.html"
}
}
Now, everything works except the redirect which never works. However, I have just noticed that if I don't use DNS and use IP instead, the redirect works just fine. Can you explain why?
Recent Discussions
Related Content
* 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
