Skip to content

LighttpdConfiguration

tslocum edited this page Nov 26, 2010 · 2 revisions

lighttpd configuration

Courtesy Harry Roberts [email protected]

# Force www to go to main domain (without www)
$HTTP["host"] == "dumpch.cn" {
        # Redirect imageboards to correct domain
        url.redirect = (
                "^/([a-z]{1,2}/.*)$" => "http://img.dumpch.cn/$1",
                "^/([a-z]{1,2}/?)$" => "http://img.dumpch.cn/$1/",
        )
} else $HTTP["host"] == "cgi.dumpch.cn" {
        # Pass off pyib to fastcgi process
        fastcgi.server = ( "pyib.py" =>
          ((
                "bin-path" => "/home/pyib/pyib-app/pyib.py",
                "socket" => "/tmp/pyib.socket",
                "max-procs" => 1,
                "idle-timeout" => 20,
                "bin-copy-environment" => (
                        "PATH", "SHELL", "USER"
                )
          ))
        )
        url.rewrite-once = ( "^/(.*)" => "/pyib.py/$1" )
        url.redirect = (
                "^/static/(.*)" => "http://dumpch.cn/static/$1"
        )
        server.document-root = "/home/pyib/pyib-app"
} else $HTTP["host"] == "img.dumpch.cn" {
        server.document-root = "/mnt/img"
        # Aggressively cache images
        $HTTP["url"] =~ "^/[^/]+/(src|thumb)/" {
                expire.url = ( "" => "access 6 months" )
        }
        # Slow down bulk-downloads
        $HTTP["url"] =~ "^/[^/]+/src/" {
                connection.kbytes-per-second = 75
        }
        # Never cache htm files, allowing for instant update after re-build
        $HTTP["url"] =~ "\.html$" {
                setenv.add-response-header = (
                        "Cache-Control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
                        "Pragma" => "no-cache"
                )
        }
        url.redirect = (
                "^/static/(.*)" => "http://dumpch.cn/static/$1"
        )
}
Clone this wiki locally