Lighttpd block wget useragent for specific urls
One of regular reader asks a question:
My website powered by Lighttpd web server. I’d like to block Wget useragent for entire my domain.com site except for /downloads/ url section. How do I configure lighttpd?
You need to use $HTTP filed useragent and url combination. Just open your lighttpd.conf file and append code as follows.
Lighttpd block useragent wget configuration
# vi /etc/lighttpd/lighttpd.conf
Append config directive as follows:
$HTTP["useragent"] =~ "Wget" {
$HTTP["url"] !~ "^/download($|/)" {
url.access-deny = ( "" )
}
}
Where,
- $HTTP["useragent"] : Match on useragent i.e. Wget
- $HTTP["url"] : Match on url section such as /download/*. If there are nested blocks, this must be the most inner block.
- =~ : Perl style regular expression match
- !~ : Perl style regular expression not match
Just restart the webserver, enter:
# /etc/init.d/lighttpd restart
Now user can run wget on http://domain.com/download/* urls but not on http://domain.com/file.html or http://domain.com/dir/file
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or full RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in...
- Lighttpd prevent image hotlinking or leeching or direct linking
- The rise of bots, spammers, crack attacks and libwww-perl
- Lighttpd: redirect feed traffic to a Feedburner account
- Lighttpd restrict or deny access by IP address
- Lighttpd / Apache : Run Xcache in Chrooted Jail
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: block_useragent, lighttpd, perl_regex, wget_command ~ Last updated on: August 12, 2007



This is pointless imo.
Users will still be able to use wget on your whole domain if they use wget –user-agent ….