Many of our regular readers like to know more about lighttpd hotlink protection using mod_rewrite. Lighttpd can use HTTP referer to detect hotlink and can be configured to partially protect hosted media from inline linking, usually by not serving the media or by serving a different file.
Lighttpd anti hotlinking configuration - redirect to another media
Open lighttpd.conf configuration file:
# vi /etc/lighttpd/lighttpd.conf
Append following directive to redirect to a default picture called /hotlink.png:
$HTTP["referer"] =~ ".*BADDOMAIN\.com.*|.*IMAGESUCKERDOMAIN\.com.*|.*blogspot\.com.*" {
url.rewrite = ("(?i)(/.*\.(jpe?g|png))$" => "/hotlink.png" )
}
So if anyone from *.blogspot.com linked www.cyberciti.biz/image.png it will be replaced with www.cyberciti.biz/hotlink.png. I've written small script to detect excessive hotlink from log file and ban all those domains. Most types of electronic media can be redirected this way, including video files, music files, and animations etc.
Related: Apache web server user can stop lechers using mod_rewrite / .htaccess rules.
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- 10 Greatest Open Source Software Of 2009
- My 10 UNIX Command Line Mistakes
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
- Email this to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: Jun/12/2008



{ 1 comment… read it below or add one }
Hello Vivek!
Thank you very much for this entry.
You could copy the script for autoban domains with excessive hotlinking?