Forum Discussion
Dave_Noonan
Feb 18, 2020Cirrus
Your code looks a lot like what I came up with after further searching, so that's reassuring.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::path]] {
"/blahblah/app/*" -
"/blahblah/api/*" {
# If client is public IP then send 404
if { not ([class match [IP::client_addr] equals private_net]) } {
HTTP::respond 404 content "HTTP ERROR 404 Reason:Not Found" Mime-Type "text/html"
event disable
TCP::close
} else {
# If client is private IP set cookie persistence
persist cookie insert blahblah_Cookie 0
}
}
}
}
The second question is just to block those from non-RFC1918 IP space. I included that in my irule but feel free to tell me if there's a better way.