lighttpd forum lighty > Restrict access by referer, but allow ip

Posted by Vlad Rosca
on 06.05.2008 13:22
Hello everyone,

I started using referer blocking in order to stop hot-linking and 
bandwidth stealing, but I hit a little "snag": my website uses a "get 
header" command to check if the files offered for download are actually 
on the server, but because the referer block is in place, this check now 
fails every time it's run.

The only solution is to somehow allow certain ips (the localhost) to 
access the files, while blocking everyone else if they don't have the 
referer.

My current referer blocking syntax looks like this:

$HTTP["referer"] !~ "domain\.com" {
  url.access-deny = ( ".zip", ".rar", ".dmg", ".bin", ".sh" )
}

But I need something along the lines of:

$HTTP["referer"] !~ "domain\.com" {
   $HTTP["remoteip"] !~ "192.168.1.1" {
  url.access-deny = ( ".zip", ".rar", ".dmg", ".bin", ".sh" )
}

The problem is that I can't get it to work properly, as Lighttpd gives a 
parsing error if I try to include the IP check beside the refer one.

Is there any way to get around this problem?