we need to create a startup file in the /etc/init.d folderGo here to download the startup script http://redmine.lighttpd.net/projects/lighttpd/wiki/ScriptsUbuntucreate a file called lighttpd in the /etc/init.d/ folder and then

chmod a+x /etc/init.d/lighttpd

Create a user to run lighttpd: if you have installed lighttpd 1.4 from apt or apache you can just use the www-data user again

adduser -m -d /var/www -s /sbin/nologin lighttpd

Modify the lighttpd file from /etc/init.d/ to match the user you want to run it as

You can also enable other modules that you need, mod_cache has to be enable first!cache.bases = ("/var/cache/lighttpd")cache.enable = "enable"cache.support-queries = "enable"cache.debug = "enable"cache.dynamic-mode = "enable"Change

Saturday, April 11, 2009

Here's how I manage traffic on my web site that's served over a basic cable connection. The site has a forum and an area for register members to download stuff from. Having a very limited upload capacity I have to make sure members don't suck everything and make the forum unresponsive.

So here's how my lighttpd.conf file is setup:

# this limits the amount of connection a user can make to the server

evasive.max-conns-per-ip = 10

# then on my site configuration I use a combination of connection.kbytes-per-secon and evasive.max-conns-per-ip to throttle user connections to the download script

$HTTP["host"] =~ "sitegeisha\.dyndns\.dk" {

connection.kbytes-per-second = 64

$HTTP["url"] =~ "dl\.php" {

connection.kbytes-per-second = 32

evasive.max-conns-per-ip = 3

}

}

This configuration allows me to limit the number of simultaneous downloads they can make, if they go over 3 they get a 403 error message.