HowFlow


HowFlow — This trick shows how to configure Lighttpd to deliver static content directly and proxy the requests to dynamic content to Mongrel, Thin or whatever.

Share it!   Posted by Hoodow Hoodow 7 months ago


$HTTP["host"] == "your.host.com" {
        var.appdir = "/path/to/your/app/" 

        accesslog.filename = "/var/log/lighttpd/yourapp.log" 
        dir-listing.activate = "disable" 

        $HTTP["url"] =~ "^/(images|stylesheets|javascripts)/(.*)$" {
                server.document-root = appdir + "public/" 

                $HTTP["url"] =~ "^/(images|stylesheets|javascripts)/" {

                     # feel free to add stuff like 
                     #    expire.url = ( "" => "access 3 days" )
                     # or 
                     #    deflate.enabled = "enable" 
                     # here

                }
        }
        else $HTTP["host"] == "your.host.com" {
        proxy-core.protocol = "http" 
        proxy-core.balancer = "sqf" 
        proxy-core.backends = ( "unix:/var/tmp/yourapp.0.sock",
                                "unix:/var/tmp/yourapp.1.sock",
                                "unix:/var/tmp/yourapp.2.sock",
                                "unix:/var/tmp/yourapp.3.sock",
                                "unix:/var/tmp/yourapp.4.sock" )
        }
}


Please log in or sign up and vote for this trick if it was helpful for you.
Don't forget to subscribe to our RSS Feed RSS/Atom feed to get the latest tricks.