shakalakka
Altostratus
Aug 22, 2022iRule and multiple switch-statements
So we need to filter based on both URIs and host-headers AND the source-IPs. I have tried using two switch-statements, with the same action for both if the client-IP-range matches - the first one works, but the second one doesnt seem to be evaluated. Any tips?
iRule:
when HTTP_REQUEST {
set RESPONSE "<html><title>404 - NOT FOUND</title><body>404 - not found</body></html>"
switch -glob [string tolower [HTTP::uri]] {
"/someuri" -
"/someuri/*" {
if { [matchclass [IP::client_addr] equals dg_blockthesehosts ] } {
HTTP::respond 404 -version auto content $RESPONSE noserver "Content-Type" "text/html;charset=utf-8"
TCP::close
event disable
return
}
}
}
switch -glob [string tolower [HTTP::host]] {
"Host1.host.com" -
"Host2.host.com" {
if { [matchclass [IP::client_addr] equals dg_blockthesehosts ] } {
HTTP::respond 404 -version auto content $RESPONSE noserver "Content-Type" "text/html;charset=utf-8"
TCP::close
event disable
return
}
}
}
}