Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment
up vote 0 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.