Lighttpd with auth and ssl

SSL

  • openssl req -new -x509 -keyout /etc/lighttpd/certs/lighttpd.pem -out /etc/lighttpd/certs/lighttpd.pem -days 365 -nodes
  • chmod 400 /etc/lighttpd/certs/lighttpd.pem
  • insert the below code into /etc/lighttpd/lighttpd.conf
$SERVER["socket"] == ":443" {
  ssl.engine = "enable" 
  ssl.pemfile = "/etc/lighttpd/certs/lighttpd.pem" 
}

Auth

  • htdigest -c /etc/lighttpd/.passwd 'Authorized users only' user
  • nano /etc/lighttpd.conf
  • add server.modules += ( "mod_auth" )
  • also insert the below
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/etc/lighttpd/.passwd"
auth.debug = 2
auth.require = ( "/" =>
(
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
)
)