I finally got a rails application working nicely (this weblog!) but then needed to make it public. The problem was that it’s too difficult to set up fastcgi with Apache2, so I wanted to run lighttpd (or webrick).
Apache listens on port 80, so I needed to get it to proxy requests to lighttpd running on a different port - and make this transparent.
I had blog.rikkus.info in DNS already, so I make a new configuration file in /etc/apache2/sites-enabled
I already have files called 000-default, 001-ssl and 010-forum, so I named this file 020-blog
This file contains the following:
<VirtualHost *:80>
ServerName blog.rikkus.info
ServerAdmin rik@rikkus.info
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>
Simple, when you know how.
Once I had set this up, I realised that I wasn’t getting the correct IPs in my lighttpd log file. This was easily fixed by adding this line to my lighttpd.conf:
accesslog.format = "%{X-Forwarded-For}i %s %m %U %q"
X-Forwarded-For can have a comma separated list of addresses - it seems that it is appended to. I don’t find this a problem, myself.
Note that the rest of the format is just what I wanted to see. If you want different stuff, check the lighttpd manual - access log.