Redirect from HTTP to HTTPs in lighthttpd
Solution 1
$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.
Solution 2
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..."
Related videos on Youtube
rodzusa
Updated on September 18, 2022Comments
-
rodzusa over 1 year
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 with127.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
-
ikwyl6 almost 5 yearsI get this when using url.redirect: (server.c.1550) WARNING: unknown config-key: url.redirect (ignored). Using lighttpd 1.4.54
-
dgnuff about 2 yearsYou might want to note that this also requires the use of
mod_redirect
, so adding the lineserver.modules += ( "mod_redirect" )
to your config file may be necessary. At least it was for me with lighttpd 1.4.55