【问题标题】:How do you restrict access to certain paths using Lighttpd?您如何使用 Lighttpd 限制对某些路径的访问?
【发布时间】:2008-12-13 01:55:12
【问题描述】:

我想限制对我的/admin URL 的访问仅限于内部 IP 地址。开放互联网上的任何人都应该无法登录我的网站。由于我使用的是 Lighttpd,我的第一个想法是使用 mod_rewrite 将任何外部对 /admin URL 的请求重定向回我的主页,但我对 Lighty 知之甚少,文档也没有多说检测到 192.168.0.0 IP 范围。

【问题讨论】:

    标签: mod-rewrite redirect admin lighttpd


    【解决方案1】:

    试试这个:

    $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 = ( "" )
        }
      }
    

    【讨论】:

    • 我如何使用这种结构限制单个路径(即 /admin)?
    • $HTTP["host"] == "www.example.org" { $HTTP["remoteip"] != "10.0.0.0/8" { $HTTP["url"] = ~ "^/admin/" { url.access-deny = ( "" ) } } }
    【解决方案2】:

    这对我有用:

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

    != 工作于==

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-20
      • 2016-07-07
      • 2012-07-18
      相关资源
      最近更新 更多