Remote IP lost when using Lighttpd + Pound -- use Lighttpd + Pen instead

If you’ve tried following the latest advice on Rails server setup over at the Riding Rails blog, you’ll have found that it breaks the request.remote_ip by making it always return 127.0.0.1. Useless.



The problem is that Pound blindly insists on adding an X-Forwarded-For header to every request it passes, whether or not that header is already present. Consequently, it overrides the X-Forwarded-For header already added by Lighttpd, and information about the originating IP is lost.



The solution is to drop Pound and replace it with another proxy that handles the X-Forwarded-For header more intelligently. I’ve decided on Pen, where you can simply leave out the “-H” command line option and everything works. See the documentation for Pen + Mongrel for more details.



Another advantage is that there’s no funky configuration issues, like crashing without any messages when you leave out a configuration option that the documentation doesn’t say is required.

2 comments

Hey there, I find that when Pound is in front of Lighty, everything works much better. I just wrote up an article on it. See what you think: http://blog.tupleshop.com/articles/2006/07/08/deploying-rails-with-pound-in-front-of-mongrel-lighttpd-and-apache
By Rob Orsini on Sun, Jul 09, 06 at 10:11 · Reply
  Cancel
Interesting, thanks for the link. One thing I like about the Pen setup is that it's literally a two-line setup: <code>apt-get install pen pen 7999 localhost:8000 localhost:8001 localhost:8002</code> That's roughly what my setup and config looks like. That's simple.
By Lars Pind on Sun, Jul 09, 06 at 10:11 · Reply
  Cancel

Leave a comment