prevent hotlinking in lighttpd

From WebHostingNeeds.com
Jump to: navigation, search

On video site, i used to get hotlink from site sayimg.org

124.87.34.210 s1.video.bizhat.com - [30/Jan/2010:15:03:43 +0000] "GET /dl/09f99785f53c29e9ff514cff57aa74b7/4aaa6991/4ca4238a0b/12526819621122107652.flv HTTP/1.1" 403 345 "http://www.sayimg.org/movie.swf/[[DYNAMIC]]/1" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Sleipnir/2.7.2"

To prevent hotlink from the site, add following to lighttpd.conf

$HTTP["referer"] =~ ".*sayimg\.org.*" {
url.access-deny = ( "" )
}

Restart ligttpd, to verify hotlinking is disabled, run

[[email protected] ~]# wget --referer ww.sayimg.org http://s1.video.bizhat.com/index.html
--15:08:28--  http://s1.video.bizhat.com/index.html
Resolving s1.video.bizhat.com... 76.76.18.22
Connecting to s1.video.bizhat.com|76.76.18.22|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
15:08:28 ERROR 403: Forbidden.

[[email protected] ~]#

Prevent Hotlink from all domain other than bizhat.com

$HTTP["referer"] !~ "^($|.*bizhat.*)" {
    url.access-deny = ( "" )
}