Irule help to block HTTP request if the HTTP Referer header value is null or with wrong domain
Hello Team,
I'm in need of an Irule to block HTTP request if the HTTP Referer header value is null or with wrong domain address.
Could you please help with an irule for this request?
when HTTP_REQUEST {
set referer [string tolower [HTTP::header value "Referer"]]
if {($referer != "") && !($referer starts_with "*.abc.com")} {
log local0.info "Rejecting request to [HTTP::uri] with Referer $referer"
reject
}
}
I have also tried the below irule and this also not worked.
Class allowed_referers {
*.abc.com
}
when HTTP_REQUEST {
set referer [string tolower [HTTP::header value "Referer"]]
if { ( [matchclass [HTTP::header value "Referer"] $referer contains allowed_referers ] ) }
{
allow
}
}
Regards,
Thiyagu