Forum Discussion
SanjayP
Nov 30, 2021Nacreous
It'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
}
}
}