Lighttpd - 認證使用者
# vi /etc/lighttpd/modules.conf
"mod_auth", //將註解拿掉
2. 加入認證使用者
# vi /etc/lighttpd/.plain_users
darwin:123456
3. 編輯vhosts.conrf檔案
# vi /etc/lighttpd/conf.d/vhosts.conf
可以在你要的虛擬主機加上這段, 即可認證
$HTTP["host"] == "http://www.aaa.com/" {
server.name="http://www.aaa.com/"
server.document-root="/var/lighttpd/blog.aaa.com"
server.errorlog="/var/log/lighttpd/blog.aaa.com.error.log"
accesslog.filename="/var/log/lighttpd/blog.aaa.com.access.log"
}
$HTTP["host"] == "http://www.bbb.com/" { //加入http://www.bbb.com/認證
server.name="http://www.bbb.com/"
server.document-root="/var/lighttpd/blog.bbb.com"
server.errorlog="/var/log/lighttpd/blog.bbb.com.error.log"
accesslog.filename="/var/log/lighttpd/blog.bbb.com.access.log"
auth.backend = "plain"
auth.backend.plain.userfile = "/etc/lighttpd/.plain_users"
auth.require = ("/" => (
"method" => "basic",
"realm" => "Please Input UserName",
"require" => "valid-user" ))
}
4. 測試 http://www.bbb.com/