如何使用 Lighttpd 限制对某些路径的访问?

发布于 2024-07-10 19:25:07 字数 223 浏览 5 评论 0原文

我想将对我的 /admin URL 的访问限制为仅内部 IP 地址。 开放互联网上的任何人都不应该能够登录我的网站。 由于我使用 Lighttpd,我的第一个想法是使用 mod_rewrite/admin URL 的任何外部请求重定向回我的主页,但我了解不多关于 Lighty 和文档没有太多关于检测 192.168.0.0 IP 范围的信息。

I would like to restrict access to my /admin URL to internal IP addresses only. Anyone on the open Internet should not be able to login to my web site. Since I'm using Lighttpd my first thought was to use mod_rewrite to redirect any outside request for the /admin URL back to my home page, but I don't know much about Lighty and the docs don't say much about detecting a 192.168.0.0 IP range.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

邮友 2024-07-17 19:25:07

试试这个:

$HTTP["remoteip"] == "192.168.0.0/16" {
    /* your rules here */
}

docs 中的示例:

  # deny the access to www.example.org to all user which 
  # are not in the 10.0.0.0/8 network
  $HTTP["host"] == "www.example.org" {
    $HTTP["remoteip"] != "10.0.0.0/8" {
     url.access-deny = ( "" )
    }
  }

Try this:

$HTTP["remoteip"] == "192.168.0.0/16" {
    /* your rules here */
}

Example from the docs:

  # deny the access to www.example.org to all user which 
  # are not in the 10.0.0.0/8 network
  $HTTP["host"] == "www.example.org" {
    $HTTP["remoteip"] != "10.0.0.0/8" {
     url.access-deny = ( "" )
    }
  }
酷炫老祖宗 2024-07-17 19:25:07

这对我有用:

$HTTP["remoteip"] != "192.168.1.1/254" {
      $HTTP["url"] =~ "^/intranet/" {
        url.access-deny = ( "" )
      }
    }

!=== 更有效。

This worked for me:

$HTTP["remoteip"] != "192.168.1.1/254" {
      $HTTP["url"] =~ "^/intranet/" {
        url.access-deny = ( "" )
      }
    }

!= worked over ==.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文