How to redirect http requests to https in lighttpd
#./configure –with-openssl
Please edit your lighttpd.conf :
server.modules = (
”mod_rewrite”,
”mod_redirect”,
”mod_alias”,
”mod_access”,
”mod_accesslog”,
…
)
$SERVER[“socket”] == “:80” {
$HTTP[“host”] =~ “(.*)” {
url.redirect = ( “^/(.*)” => “https://%1/$1” )
}
}
$SERVER[“socket”] == “:443” {
ssl.engine = “enable”
ssl.pemfile = “/etc/lighttpd/ssl/server.pem”
ssl.ca-file = “/etc/lighttpd/ssl/server.crt”
server.name = “mahalo”
server.document-root = “/www/”
server.errorlog = “/var/logs/lighttpd/lighttpd.ssl.error.log”
accesslog.filename = “/var/logs/lighttpd/ssl.access.log”
}
—
# if you would like to rediret 8080 to 9090 you should write as below:
$SERVER[“socket”] == “:8080” {
$HTTP[“host”] =~ “(.*):8080” {
url.redirect = ( “^/(.*)” => “https://%1:9090/$1” )
}
}