代码之家  ›  专栏  ›  技术社区  ›  Adam Matan

lighttpd:如何对与regex匹配的URL进行密码保护

  •  5
  • Adam Matan  · 技术社区  · 15 年前

    有没有一种方便的方法来密码保护符合特定模式的URL Lighttpd 是吗?

    我考虑过匹配regex,但是任何其他创造性的解决方案都是不错的。

    注释 :我不想寻找密码保护目录的方法,因为我要保护的URL不局限于某个目录结构。

    亚当

    1 回复  |  直到 11 年前
        1
  •  6
  •   davethegr8 Community Driven Business    15 年前

    你看过吗 mod_auth 插件?

    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"
    )
    

    身份验证文件将包含(用于基本身份验证):

    username:password
    

    更多信息: http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModAuth

    要筛选/检查特定目录,

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