Lighttpd的目录保护

有些不想让人随便看的东西会在访问目录时认证一下,对于Lighttpd来说还是比较方便的(参照这里),可选的方式也比较多。我选择htpasswd,一个Apache的工具来生成认证文件,再通过设置lighttpd.conf开启认证。

htpasswd -bc .passwd username password

在lighttpd.conf后面添加

server.modules += ( "mod_auth" )
auth.backend = "htpasswd"

## for htpasswd
auth.backend.htpasswd.userfile = "/home/.passwd"

auth.require = ( "/path/" =>
             (
             # method must be either basic or digest
               "method"  => "basic",
               "realm"   => "download archiv",
               "require" => "user=name1|user=name2"
             )
           )