Forum Discussion
Irule help to block HTTP request if the HTTP Referer header value is null or with wrong domain
Hi Tiyagu,
Can you test this and investigate logs?
when HTTP_REQUEST {
log local0. "referer status: [HTTP::header exists Referer] | clientip: [IP::client_addr] | uri: [HTTP::uri]"
if { [HTTP::header exists "Referer"] and not ([HTTP::header value "Referer"] contains ".abc.com") } {
log local0. "referer header found | uri: [HTTP::uri]"
HTTP::respond 400 content "Bad Request" Content-Type "text/html"
}
}- ThiyaguDec 17, 2020
Cirrus
Thanks a lot eaa.
As a plan B I have also worked on the below iRULE. Could you please correct me if I' missing something ?
------------------------------------------------
when HTTP_REQUEST {
switch -glob [HTTP::header "Referer"] {
"*.abc.com/*" {
# Allow Request to go through...
}
"" {
HTTP::respond 400 content "Bad Request" Content-Type "text/html"
}
default {
HTTP::respond 400 content "Bad Request" Content-Type "text/html"
}
}
}
------------------------------------------------------------
Thanks a lot in advance
Regards,
Thiyagu
Recent Discussions
Related Content
* 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
