Skip to content

Lighttpd and Debian

Everyone knows that lighttpd is the popular choice for deploying rails applications. Although Apache can get the job done with mod_fastcgi, Apache+fastcgi seems somewhat unstable and prone to zombie processes and poor performance (at least in my experience). So when I finally needed my rails application to actually consistantly work, I decided to install lighttpd (apt-get from Debian testing). I chose the apache proxy approach so that I didn’t have to completely switch over for all my websites. Instructions here and here got me most of the way.

For reference, and your enterainment, here’s the apache proxy configuration. This took me a while to figure out and I was getting 502 Bad Gateway errors until I stumbled on the <Proxy> directive.

  ProxyPass / http://localhost:81/
  ProxyPassReverse / http://localhost:81/
  ProxyPreserveHost on
  <Proxy *>
     Order deny,allow
     Allow from all

Obviously this is only the proxy part of my vhost config and you’ll have to make sure you are forwarding to the correct port on your lightty server.

As for the lightty configuration, the above instructions worked great, except for one Debian specific thing. In the default lighttpd.conf there is this which can be used to access the Debian Policy Manual

$HTTP["host"] == "localhost" {
       global {
               alias.url += ( 
                       "/doc/" => "/usr/share/doc/",
                       "/images/" => "/usr/share/images/"
       dir-listing.activate = "enable"

Apparently, this sets up two global aliases for “doc” and “images”. And guess what, rails.png is not in /usr/share/images/. That is, your public/images directory in your rails app is not the /images directory that lightty is accessing with the above configuration in place. Comment out those lines and you should be good to go.