【问题标题】:Allow directory access for certain IP's at Lighttpd在 Lighttpd 允许某些 IP 的目录访问
【发布时间】:2011-11-22 21:03:29
【问题描述】:

我需要重写这个规则(来自 apache 的 .htaccess):

<files "*.*">
Allow from 84.47.125.0/19 66.211.160.0/19 216.113.160.0/19
Deny from All
</files>

对 lighttpd 来说,只允许那些 IP 访问我的 /pswd 目录:

84.47.125.0/19, 66.211.160.0/19, 216.113.160.0/19

如何在 lighttpd 中做到这一点?

【问题讨论】:

    标签: .htaccess lighttpd access-control


    【解决方案1】:

    我从未使用过 lighttpd,但我在 Google 上找到了这个: http://www.cyberciti.biz/tips/lighttpd-restrict-or-deny-access-by-ip-address.html

    它有一个阻止 2 个 ip 访问和阻止单个 ip 的示例。这样做应该很容易适应你:

    # vi /etc/lighttpd/lighttpd.conf
    

    然后:

    $HTTP["remoteip"] !~ "84.47.125.0/19|66.211.160.0/19|216.113.160.0/19" {
        $HTTP["url"] =~ "^/pswd/" {
          url.access-deny = ( "" )
        }
     }
    

    我希望这会有所帮助。

    【讨论】:

    • 好吧,它似乎不起作用,因为当我使用:"84.47.125.0/19|66.211.160.0/19|216.113.160.0/19" 那些 IP(甚至我,无法访问文件夹 /ipn/)。
    • 只需将第一行中的 !~ 替换为 =~
    猜你喜欢
    • 2012-08-03
    • 2012-09-20
    • 1970-01-01
    • 2020-09-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-09
    • 2017-05-22
    • 2023-03-15
    相关资源
    最近更新 更多