Forum Discussion
Edgar_Palamarch
Nimbostratus
Jul 05, 2012Referer Based Redirect
Hello,
A former client is leaching images from our website. So, I need to redirect/block requests coming from them based on the referer header. Found a couple sample codes, but couldn't make...
nitass
Employee
Jul 05, 2012can you try to change from "http://BadReferer.com" to "BadReferer.com"?
e.g.
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.19.79:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
set referrer_host [URI::host [HTTP::header value Referer]]
log local0. "\[HTTP::uri\]: [HTTP::uri]"
log local0. "\[HTTP::header value Referer\]: [HTTP::header value Referer]"
log local0. "\[URI::host [HTTP::header value Referer]\]: [URI::host [HTTP::header value Referer]]"
if { $referrer_host eq "BadReferer.com" } {
HTTP::redirect http://BadReferer.com/image.jpg
}
}
}
[root@ve10:Active] config curl -I http://172.28.19.79 -H "Referer: http://BadReferer.com/something"
HTTP/1.0 302 Found
Location: http://BadReferer.com/image.jpg
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config tail /var/log/ltm
Jul 6 07:28:46 local/tmm info tmm[5111]: Rule myrule : [HTTP::uri]: /
Jul 6 07:28:46 local/tmm info tmm[5111]: Rule myrule : [HTTP::header value Referer]: http://BadReferer.com/something
Jul 6 07:28:46 local/tmm info tmm[5111]: Rule myrule : [URI::host http://BadReferer.com/something]: BadReferer.com
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