Conditional Proxying with Lighttpd

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"] =~ "" {
  server.document-root = "/var/rails/myapp/current/public"
  proxy.balance = "fair" 
  $HTTP["url"] !~ "^/(images|stylesheets|javascripts)" {
    proxy.server  = ( "/" => (
      ( "host" => "", "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.