Forum Discussion
sathish_2826
Nimbostratus
Jan 03, 2020Security headers irule issue
Hi there, i have been trying to apply an Irule to block requests for a URL when the domain is other than the ones allowed in the below rule, when HTTP_REQUEST { switch -glob [HTTP::header "R...
Yoann_Le_Corvi1
Cumulonimbus
Jan 03, 2020Hopefully this does the trick 🙂
when HTTP_REQUEST {
set domains { "xxxx.net" "xxxx.com" }
set matched 0
foreach header { "Referer" "Origin" "X-Forwarded-Host" } {
log local0. "$header - [HTTP::header $header] : [lsearch -exact $domains [HTTP::header $header]]"
if { ! ( [lsearch -exact $domains [HTTP::header $header]] equals "-1" ) } {
incr matched
}
}
if { $matched > 0 } {
pool emx-pool
} else {
HTTP::respond 200 content "
<HTML>
<HEAD>
<TITLE>Rejected Request</TITLE>
</HEAD>
<BODY>The request was rejected. <BR>The server is trying to redirect the client to an external site, but it is forbidden</BODY>
</HTML>"
}
}Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects