Redirect from HTTP to HTTPs in lighthttpd

httphttpslighttpdredirection

How can I redirect from HTTP to HTTPS with lighthttpd?

There are tons of lighttpd config snippets floating around to make this happen, but so far none of these really worked. Currently I am still playing around with 127.0.0.1, so if anyone has an adequate config in use, that would be great.

My lighttpd version is 1.4.29, OS Arch Linux 64bit

Best Answer

$SERVER["socket"] == ":443" {
        ssl.engine = "enable"
        ssl.pemfile = "/path/to/pem/file/unknown.pem"
}


$SERVER["socket"] == ":80" {
        $HTTP["host"] =~ "(.*)" {
                url.redirect = ( "^/(.*)" => "https://%1/$1" )
        }
}

solved it for me.

Related Question