lighttpd安全认证设置实践

背景:使用lighttpd作为远程调用的服务端,显然需要安全机制
Step1) 修改lighttpd.conf
打开mod_auth
server.modules += ( "mod_auth" )
另外修改:
auth.debug = 2
auth.backend = "plain"
auth.backend.plain.userfile = "/etc/lighttpd/.lighttpdpassword"
注意:
  • auth.debug = 2 : Specify debug level (0 turns off debug message, 1 for authentication ok message and 2 for detailed/verbose debugging message). This is useful for troubleshooting authentication problem. It logs message in access.log and error.log files
  • auth.backend = “plain” : You are using plain text backend (other options are ldap, htpasswd and others)
  • auth.backend.plain.userfile = “/etc/lighttpd/.lighttpdpassword” : Filename of the username:password storage
再添加以下红色的部分
$HTTP["host"] == "theos.in" {
…………………….
server.document-root = "/home/lighttpd/theos.in/http"
server.errorlog = "/var/log/lighttpd/theos.in/error.log"
accesslog.filename = "/var/log/lighttpd/theos.in/access.log"
auth.require = ( "/docs/" =>
(
"method" => "basic",
"realm" => "Password protected area",
"require" => "user=vivek"
)
)
……………...
}
注意:
  • auth.require = ( “/docs/” => : Directory name
  • “method” => “basic”, : Authentication type
  • “realm” => “Password protected area”, : Password realm/message
  • “require” => “user=vivek” : Only user vivek can use /docs/
Step 2) 产生密码文件.lighttpdpassword
# vi /etc/lighttpd/.lighttpdpassword
添加用户名密码
vivek:mysecretepassword
注意:
  • vivek - is the name of a user. Please note that do not use a system user stored in /etc/passwd file. It is recommended that you use a different username that only exists for the purpose of authenticating password protected directories.
  • mysecretepassword - is the password for user vivek (must be in clear text format for plain text method)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值