Not everyone chooses to go the FCGI way of deploying their web applications. Some people, like I, prefer deploying applications under Catalyst's httpd or Rails' Mongrel. Unfortunately, Lighttpd at this time (version 1.4.13) has a inept mod_proxy module. It does not load balance correctly and nor does it recover from a downed proxy node, requiring a full restart. Obviously this is unacceptable when it comes to a production system.

Pound comes in and saves the day. It is a fast load balancing proxy that claims it can handle 600 requests/sec. The deployment of choice here is Lighttpd => Pound => web application. However, there is a small snag, Pound appends X-Forwarded-for headers without an option to disable it. So every request that comes in from Pound to your web application comes with "X-Forwarded-For: 127.0.0.1." This means you can't tell from where the client came from. Here is the solution to remedy this issue, but it requires some hacking on the Pound source.
Open http.c and comment out line 902 and 903
==
==
You basically want to comment out the top two lines. With this out of the way Pound does not append the extra X-Forwarded-for headers. You should now be able to receive the originating IP address of the client connected to your web application.
Now to finish up. Configuring Lighttpd to pass along to Pound and then to your web application.
Sample Lighttpd configuration
$HTTP["host"] =~ "^letsgetdugg.com$|^www.letsgetdugg.com$" {
server.document-root ="/home/victori/servers/letsgetdugg/root"
dir-listing.activate = "disable"
accesslog.filename = "/var/www/lighttpd/log/letsgetdugg.access.log"
server.errorlog = "/var/www/lighttpd/log/letsgetdugg.error.log"
$HTTP["url"] !~ "static/" {
proxy.server = ( "" => ( "Letsgetdugg" => ( "host" => "127.0.0.1" , "port" => 7999, "check-local" => "disable" )))
}
}
We make sure that anything in /static does not get sent to your web application but gets processed by Lighttpd.
Sample Pound configuration
ListenHTTP
Address 127.0.0.1
Port 7999
Service
HeadRequire "Host: .*letsgetdugg.com.*"
BackEnd
Address 127.0.0.1
Port 9010
End
BackEnd
Address 127.0.0.1
Port 9011
End
BackEnd
Address 127.0.0.1
Port 9012
End
End
Thats all! This deployment should suffice till Lighttpd 1.5 goes stable.