Conditional Proxying with Lighttpd

28 Jul 2006

Let’s say you have a pretty typical lighttpd -> mod_proxy -> mongrel configuration for your Rails app. You’d rather not proxy requests for static files like stuff in the images directory to mongrel. A quick search of the lazy web didn’t turn up a copyable example for me, so here you go:

$HTTP["host"] =~ "example.com" {
  server.document-root = "/var/rails/myapp/current/public"
  proxy.balance = "fair"
  $HTTP["url"] !~ "^/(images|stylesheets|javascripts)" {
    proxy.server  = ( "/" => (
      ( "host" => "127.0.0.1", "port" => 2000 )
    ) )
  }
}

So there you go … now lighty won’t even attempt to proxy to mongrel anything URL that we know will be static, but instead will serve it up itself.

Oh, and don’t forget to take out the backslashes from before the quotes. WP is dumb.



Book Update Coming Soon

16 Jul 2006

A few people have asked when there will be an update to my book on building ecommerce applications using Ruby on Rails, since it’s now been about a month since its initial release. My goal is to have an update available within two to three weeks. I was hoping to have something a little sooner, but of course life has a way of changing your plans. At any rate, yes, I am working on an update, and yes, I do intend for it to be released soon. If you’ve been patiently waiting, thanks for hanging in there. If there’s anything in particular you feel could use more coverage in the book, feel free to add a comment to this post or send me an email