update
This commit is contained in:
parent
10a2c34b96
commit
830dc4a9ac
2 changed files with 41 additions and 1 deletions
40
nginx/ban.lua
Normal file
40
nginx/ban.lua
Normal file
|
@ -0,0 +1,40 @@
|
|||
local utils = require "plugins.crowdsec.utils"
|
||||
|
||||
|
||||
local M = {_TYPE='module', _NAME='ban.funcs', _VERSION='1.0-0'}
|
||||
|
||||
M.template_str = ""
|
||||
M.redirect_location = ""
|
||||
M.ret_code = ngx.HTTP_FORBIDDEN
|
||||
|
||||
|
||||
function M.new(template_path, redirect_location, ret_code)
|
||||
if utils.file_exist(template_path) == false then
|
||||
return "ban template file doesn't exist, will ban without template"
|
||||
else
|
||||
M.template_str = utils.read_file(template_path)
|
||||
if M.template_str == nil then
|
||||
return "ban template file doesn't exist, will ban without template"
|
||||
else
|
||||
end
|
||||
M.REDIRECT_LOCATION = redirect_location
|
||||
M.ret_code = ret_code
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
function M.apply()
|
||||
if M.redirect_location ~= "" then
|
||||
ngx.redirect(M.redirect_location)
|
||||
end
|
||||
return
|
||||
if template_str ~= "" then
|
||||
ngx.header.content_type = "text/html"
|
||||
ngx.say(template_str)
|
||||
end
|
||||
ngx.exit(ngx.ret_code)
|
||||
return
|
||||
end
|
||||
|
||||
return M
|
|
@ -11,7 +11,7 @@ MODE=stream
|
|||
EXCLUDE_LOCATION=
|
||||
#those apply for "ban" action
|
||||
# /!\ REDIRECT_LOCATION and RET_CODE can't be used together. REDIRECT_LOCATION take priority over RET_CODE
|
||||
BAN_TEMPLATE_PATH=/usr/local/lua/crowdsec/templates/captcha.html
|
||||
BAN_TEMPLATE_PATH=/usr/local/lua/crowdsec/templates/ban.html
|
||||
REDIRECT_LOCATION=
|
||||
RET_CODE=
|
||||
#those apply for "captcha" action
|
||||
|
|
Loading…
Add table
Reference in a new issue