Forum Discussion
Sabir_Alvi
Altocumulus
Nov 26, 2021iRule to allow traffic based on certain URI and remote IP, allow all if URI doesn't match
I'm looking for an iRule that will be applied to a multitenant environment, where each client will have their own set of Authorised IPs. Our application will have a "common" URI in web requests for ...
spalande
Nacreous
Nov 30, 2021It's not clear from the requirement if other host (other than starbucks.net) need any IP restrictions for certain uri, but considering they don't need it, we can simplify iRule as below. It also has mapping from host name to pool in the same iRule.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"www.abc.com"
{
pool www.abc.com_443
}
"starbucks.net"
{
pool starbucks.net_443
} default {
reject
}
}
switch -glob [string tolower [HTTP::uri]] {
"/store/coffee/mug.html"
{
if { [string tolower [HTTP::host]] eq "starbucks.net" and ![class match [IP::client_addr] equals datagroup_whitelist]} {
HTTP::respond 403 content "<html code for custom error page>"
} else {
return
}
} default {
return
}
}
}
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