lua plugin system
This commit is contained in:
parent
dcb1a04d53
commit
8f81538b0d
3 changed files with 83 additions and 3 deletions
|
|
@ -101,6 +101,15 @@ http {
|
|||
certificate = res
|
||||
end
|
||||
{{ end }}
|
||||
|
||||
ok, res = pcall(require, "plugins")
|
||||
if not ok then
|
||||
error("require failed: " .. tostring(res))
|
||||
else
|
||||
plugins = res
|
||||
end
|
||||
-- load all plugins that'll be used here
|
||||
plugins.init({})
|
||||
}
|
||||
|
||||
init_worker_by_lua_block {
|
||||
|
|
@ -109,6 +118,8 @@ http {
|
|||
{{ if $all.EnableMetrics }}
|
||||
monitor.init_worker()
|
||||
{{ end }}
|
||||
|
||||
plugins.run()
|
||||
}
|
||||
|
||||
{{/* Enable the real_ip module only if we use either X-Forwarded headers or Proxy Protocol. */}}
|
||||
|
|
@ -976,11 +987,11 @@ stream {
|
|||
rewrite_by_lua_block {
|
||||
lua_ingress.rewrite({{ locationConfigForLua $location $server $all }})
|
||||
balancer.rewrite()
|
||||
plugins.run()
|
||||
}
|
||||
|
||||
{{ if shouldConfigureLuaRestyWAF $all.Cfg.DisableLuaRestyWAF $location.LuaRestyWAF.Mode }}
|
||||
|
||||
access_by_lua_block {
|
||||
{{ if shouldConfigureLuaRestyWAF $all.Cfg.DisableLuaRestyWAF $location.LuaRestyWAF.Mode }}
|
||||
local lua_resty_waf = require("resty.waf")
|
||||
local waf = lua_resty_waf:new()
|
||||
|
||||
|
|
@ -1021,8 +1032,10 @@ stream {
|
|||
{{ end }}
|
||||
|
||||
waf:exec()
|
||||
{{ end }}
|
||||
|
||||
plugins.run()
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
header_filter_by_lua_block {
|
||||
{{ if shouldConfigureLuaRestyWAF $all.Cfg.DisableLuaRestyWAF $location.LuaRestyWAF.Mode }}
|
||||
|
|
@ -1030,6 +1043,8 @@ stream {
|
|||
local waf = lua_resty_waf:new()
|
||||
waf:exec()
|
||||
{{ end }}
|
||||
|
||||
plugins.run()
|
||||
}
|
||||
body_filter_by_lua_block {
|
||||
{{ if shouldConfigureLuaRestyWAF $all.Cfg.DisableLuaRestyWAF $location.LuaRestyWAF.Mode }}
|
||||
|
|
@ -1049,6 +1064,8 @@ stream {
|
|||
{{ if $all.EnableMetrics }}
|
||||
monitor.call()
|
||||
{{ end }}
|
||||
|
||||
plugins.run()
|
||||
}
|
||||
|
||||
{{ if (and (not (empty $server.SSLCert.PemFileName)) $all.Cfg.HSTS) }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue