Luawaf configuration View tool
Reason: in openresty-waf applications, it is common practice to save configuration information to ngx.shared.config. Each check rule configuration is then read from here.
Sometimes the problem of incorrect configuration reading is encountered, which affects the progress of troubleshooting.
So write a small function that is easy to view and configure.
A simple configuration page is written in lua to make it easy to view the current configuration:
Location / show {default_type text/html Content_by_lua_block {local config = ngx.shared.config local keys = config:get_keys (512) ngx.print ('') for I K in pairs (keys) do local str = ((nil ~ = str) and str.. [[#]] .config: get (k) or config:get (k) ngx.say (") ngx.say (k.." = > ".. str) ngx.say (") end ngx.say ()}}
The principle is to read the configuration of ngx.shared.config and note that the xmp tag is used to prevent the pit displayed by xss.