How to configure LigHTTPd (aka Lighty)

Just sharing some notes here cause I don;t have anywhere better to put them. :)

Deny access to subdir

# deny access to /data
$HTTP["url"] =~ "^/data" {
    url.access-deny = ("")
}

Redirect http to https

Relies on https being enabled. Also make sure that you have mod_redirect loaded. E.g. this in your /etc/lighttpd/lighttpd.conf:

server.modules              = (
            ...
            "mod_redirect",
 )

Then this:

# redirect all http to https
$HTTP["scheme"] == "http" {
    # capture vhost name with regex conditiona -> %0 in redirect pattern
    # must be the most inner block to the redirect rule
    $HTTP["host"] =~ ".*" {
        url.redirect = (".*" => "https://%0$0")
    }
}