local host = "192.168.16.2"
local port = 6379
function getClientIp()
local headers = ngx.req.get_headers()
local ip = headers["X-Real-IP"]
if ip == nil then
ip = headers["X-Forwarded-For"]
end
if ip == "unknown" or ip == nil then
ip = ngx.var.remote_addr
end
if ip == nil then
ip = "0.0.0.0"
end
return ip
end
function ipDeny()
local ip = getClientIp()
local redis = require "resty.redis"
local red = redis:new()
red:set_timeouts(1000, 1000, 1000) -- 1 sec
local ok, err = red:connect(host, port)
if not ok then
ngx.say("failed to connect: ", err)
return
end
isDeny, err = red:sismember("ip_blacklist", ip)
return isDeny
end
function countQueue()
local redis = require "resty.redis"
local red = redis:new()
red:set_timeouts(1000, 1000, 1000) -- 1 sec
local ok, err = red:connect(host, port)
if not ok then
ngx.say("failed to connect: ", err)
return
end
count, err = red:incr("num")
return count
end
function read(filename)
local path = "/etc/nginx/conf.d"
local file = io.open(path..'/'..filename,"r")
if file == nil then
return
end
t = {}
for line in file:lines() do
table.insert(t,line)
end
file:close()
return t
end
function uaFilter()
local rules = read("user-agent")
local ua = ngx.var.http_user_agent
if ua == nil then
ngx.exit(403)
end
for _, rule in pairs(rules) do
if rule ~= "" and ngx.re.match(ua,rule,"isjo") then
ngx.exit(403)
end
end
return
end
叼茂SEO.bfbikes.com
怎么收藏这篇文章?
想想你的文章写的特别好https://www.237fa.com/
看的我热血沸腾啊https://www.ea55.com/
兄弟写的非常好 https://www.cscnn.com/
《大爸爸,小爸爸和其它故事》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/69254.html
《罗丹2017》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/165441.html
《馗降:粽邪2》恐怖片高清在线免费观看:https://www.jgz518.com/xingkong/78914.html