Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

What I do in this situation is have a small one-page site available through HTTP that contains a single page with a meta refresh tag and possibly an explanation for browsers that have redirects disabled or unsupported for some reason. Create a custom 404 error page that also does the same thing.

The meta tag should then redirect to https://127.0.0.1 or your site's external address when you allow it to be externally reachable.

I would let the page display for 5 seconds using the meta refresh saying "This site is only available through HTTPS. You should be automatically redirected in 5 seconds, if not click here..."

share|improve this answer
up vote 1 down vote accepted
$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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .