Elton's Blog

lighttpd配置之用户验证(mod_auth)

by on 七.13, 2009, under Linux

有时候需要对某些web资源做权限验证。 在lighttpd中可以这样做。
1. 激活mod_auth模块,在/etc/lighttpd/lighttpd.conf中去掉mod_auth模块前面的#
2. 下载apache相关模块

1
# emerge -av app-admin/apache-tools

3. 生成密码文件

1
2
# cd /var/lib/lighttpd/
# htdigest -c lighttpd.user.htdigest 'some text' username

其中some text是在密码提示框的标题中要显示的内容,lighttpd.user.htdigest是密码文件的文件名
执行过htdigest后,输入两边这个用户的密码后,就可以生成lighttpd.user.htdigest这个密码文件了
4. 配置lighttpd.conf文件
添加

1
2
3
auth.debug                 = 0 
auth.backend               = "htdigest"
auth.backend.htdigest.userfile = var.statedir + "/lighttpd.user.htdigest"

auth.debug 是调试级别,0表示不调试,1表示记录’auth-ok’验证成功的信息, 2表示所有详细的调试信息
在需要验证的虚机上添加以下内容

1
2
3
4
5
6
7
auth.require = ( "" =>
                         (
                                "method"  => "digest",
                                "realm"   => "some text",
                                "require" => "user=username"
                         )
                        )

auth.require后的空引号表示虚机中所有路径都需要验证,如果只是部分需要验证,那么就指定具体路径
5. 重启lighttpd,使配置生效





:,

Leave a Reply



Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit my friends!

A few highly recommended friends...