lighttpd禁止IP直接访问及防盗链设置

来自:互联网
时间:2018-09-23
阅读:
#禁止IP直接访问lighttpd服务器,禁止其他人的域名解析到lighttpd服务器进行访问,防止恶意解析
$HTTP["host"] !~ "(^|.)yourdomAIn.com$" {
url.access-deny = ("")
}
#禁止非指定网站域名访问服务器,需要开启mod_access模块
$HTTP["referer"] !~ "^($|http://.www.yourdomain.com)" {
url.access-deny = ( "" )
}

上面的是直接禁止并返回403状态,但也可以结合

url.redirect = ( "(.*)" => "your  URL" )

进行重定向到指定的页面,例如专门弄个防盗链的说明,或者是图片,前提是开启了mod_redirect模块

#### request method restrictions (v1.5.x ONLY)
# $HTTP["request-method"] !~ "^(GET|HEAD)" {
#     url.access-deny = ( "" )
#  }
#### deny access to unwanted bots or bad clients 
# $HTTP["useragent"] =~ "(Google|BadGuy)" {
#   url.access-deny = ( "" )
# }
#### access control list for hidden_dir (not for use behind proxies)
# $HTTP["remoteip"] !~ "127.0.0.1|10.10.10.2|20.10.20.30" {
#     $HTTP["url"] =~ "^/hidden_dir/" {
#       url.access-deny = ( "" )
#     }
#  }
#### url redirect requests for xiaohost.com to www.xiaohost.com
# $HTTP["host"] =~ "^(xiaohost.com)$" {
#         url.redirect = ( "/(.*)" => "http://www.%1/$1")
# }
#### stop image hijacking (anti-hotlinking)
# $HTTP["referer"] !~ "^(http://xiaohost.com|http://www.xiaohost.com)" {
#     url.access-deny = ( ".jpg", ".jpeg", ".png", ".avi", ".mov" )
# }
#### virtual host limits
# $HTTP["host"] !~ "^(xiaohost.com|www.xiaohost.com)" {
#     url.access-deny = ( "" )
#  }
#### stop referer spam
# $HTTP["referer"] =~ "(tarotathome|casinospam)" {
#     url.access-deny = ( "" )
#  }
返回顶部
顶部