如何与Cloudflare一起使用Lighttpd的$ HTTP [" remoteip"]?

时间:2014-06-22 16:37:30

标签: lighttpd cloudflare

我正在使用Clodflare DNS。我只想允许某些IP访问某些文件。

如何设置lighttpd.conf以正确检测正确的IP?我知道如何为access.log做这件事。是否可以将$ HTTP [" remoteip"]与其他内容一起使用?

今天我就是这样做的:

 $HTTP["remoteip"] == "xx.xx.xx.xx" {
    url.access-deny = ("")
}

我尝试过以下但是没有用:

 $HTTP["remoteip"] ==""{
   extforward.forwarder = ( "all" => "trust" )
   extforward.headers = ("CF-Connecting-IP")
 }

2 个答案:

答案 0 :(得分:1)

我们的知识库中实际上有一些关于CloudFlare and Lighttpd的解决方案可能会指向正确的方向。

答案 1 :(得分:0)

由于重复的IP条目,Cloudflare的设置似乎会出错。

以下是适合我的设置。我把它们放在server.modules { .. }之后:

$HTTP["remoteip"] == "199.27.128.0/21" {
extforward.forwarder = ( "all" => "trust" )
extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "173.245.48.0/20" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "103.21.244.0/22" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "103.22.200.0/22" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "103.31.4.0/22" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "141.101.64.0/18" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "108.162.192.0/18" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "190.93.240.0/20" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "188.114.96.0/20" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "197.234.240.0/22" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "198.41.128.0/17" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "162.158.0.0/15" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}
$HTTP["remoteip"] == "104.16.0.0/12" {
    extforward.forwarder = ( "all" => "trust" )
    extforward.headers = ("CF-Connecting-IP")
}

使用此$ HTTP [“remoteip”]可以正常工作。