Stop Hotlinking with Lighttpd
The technology behind the World Wide Web, the Hypertext Transfer Protocol (HTTP), does not make any distinction of types of links -- all links are functionally equal. Resources may be located on any server at any location. Linking to an image stored on another site increases the bandwidth use of that site even though the site is not being viewed as intended. The complaint may be the loss of ad revenue or changing the perceived meaning through an unapproved context.
Here is easy and simple way to stop hotlinking :
Open lighttpd.conf file:
$ vi lighttpd.conf
#### stop image hijacking (anti-hotlinking)
$HTTP["referer"] =~ ".*BADDOMIN\.com.*" {
url.access-deny = ( "" )
# url.access-deny = ( "jpg", "png", "js", "jpeg", "gif" )
}
You can also enforce password protection:
$HTTP["referer"] =~ ".*BADDOMIN\.com.*" {
auth.require = ( "/" =>
( "method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
)
)
}
Restart lighttpd:
# service lighttpd restart
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Lighttpd mod_rewrite Hotlink Protection To Display Image Message
- Lighttpd prevent image hotlinking or leeching or direct linking
- How to upgrade lighttpd tar ball (source code) installation
- Lighttpd 1.5 fastcgi php mod proxy backend fastcgi configuration howto
- How To Monitor Bandwidth With iptables
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: bandwidth theft, deny access to hotlinking, direct linking, leeching, lighttpd image linking, lighttpd stop hotlinking, offsite image grabs, piggy-backing, stop image hotlinking



Wouldn’t be wiser to block all referrers by default and instead use a white list of those allowed?
$HTTP["referer"] =~ “*” {
url.access-deny = ( “” )
}
$HTTP["referer"] =~ “.*GOODDOMIN\.com.*” {
url.access-allow = ( “” )
}
I dont’t understand this line :
url.access-deny = ( “” )
and why the line
# url.access-deny = ( “jpg”, “png”, “js”, “jpeg”, “gif” )
is commented ? does it meen that every file called out of the domain are bloqued ?