Lighttpd password protection

Activate Basic/Digest Authentication

To use authentication, you need to load ModAuth in lighttpd.conf

server.modules += ( "mod_auth" )

Protect your VirtualHost

$HTTP["host"] =~ "^(www\.domain\.com)$" {
    auth.backend = "htpasswd"
    auth.backend.htpasswd.userfile = "/etc/lighttpd/htpasswd"
    auth.require = ( "/" => ( "method" => "basic", "realm" => "Doamin", "require" => "valid-user") )
}

Protect your VirtualHost and whitelist IP addresses

$HTTP["host"] =~ "^(www\.domain\.com)$" {
    $HTTP["remoteip"] !~ "(192.168.0.*|88.191.76.232)" {
        auth.backend = "htpasswd"
        auth.backend.htpasswd.userfile = "/etc/lighttpd/htpasswd"
        auth.require = ( "/" => ( "method" => "basic", "realm" => "Doamin", "require" => "valid-user") )
    }
}