开发者

Lighttpd: How to password-protect URLs matching regex

开发者 https://www.devze.com 2022-12-18 10:11 出处:网络
Is there a convenient way to passwo开发者_如何学编程rd-protect URLs which match a certain pattern in Lighttpd?

Is there a convenient way to passwo开发者_如何学编程rd-protect URLs which match a certain pattern in Lighttpd?

I thought about matching regex, but any other creative solution will be nice.

NOTE : I'm not looking for a way to password-protect a directory, beacuse the URLs I want to protect aren't confined to a certain directory structure.

Adam


Have you looked at the mod_auth plugin?

auth.debug = 0
auth.backend = "plain"
auth.backend.plain.userfile = "/full/path/to/auth-file.txt"
auth.require = ("example.com" =>
(
"method" => "basic",
"realm" => "Password protected area",
"require" => "user=username"
)

And the auth-file would contain (for basic authentication):

username:password

More info: http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModAuth

To filter / check a specific directory,

$HTTP["url"] =~ "^/download(s)?$" {
    auth.require = ( "" =>
        (
            "method"  => "basic",
            "realm"   => "Passworded Area",
            "require" => "user=username" 
        )
    )
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号