Is your feature request related to a problem? Please describe.
If one uses openresty, there is a possibility to include Lua-Scripts into the config file with access_by_lua_block {} (and others). Those parts are parsed as default nginx-config.
Describe the solution you'd like
It would be great if the plugin would realize a language injection (or allow them with a comment or similar) and would disable nginx-language checks and - ideally - highlight the injected language (with Lua-Plugin installed). Currently, the last line of a lua_block is always considered syntactically incorrect, because of the missing ;.
Describe alternatives you've considered
Always use _lua_by_file directives and external lua files that get correctly highlighted if the Lua-Plugin is installed.
Additional context
Full List of directives from lua-nginx-module:
string based (discouraged; I would not implement this, but if it does not take much additional work, it's a nive-to-have)
init_by_lua ""
init_worker_by_lua ""
set_by_lua ""
content_by_lua ""
rewrite_by_lua ""
access_by_lua ""
header_filter_by_lua ""
body_filter_by_lua ""
log_by_lua ""
block based
init_by_lua_block { }
init_worker_by_lua_block { }
exit_worker_by_lua_block { }
set_by_lua_block { }
content_by_lua_block { }
rewrite_by_lua_block { }
access_by_lua_block { }
header_filter_by_lua_block { }
body_filter_by_lua_block { }
log_by_lua_block { }
balancer_by_lua_block { }
ssl_certificate_by_lua_block { }
ssl_session_fetch_by_lua_block { }
ssl_session_store_by_lua_block { }
Reduced config example:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name _;
set $my_nginx_var "";
location / {
access_by_lua_block {
local redis = require "resty.redis"
local red = redis:new()
red:set_timeout(200)
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
return
end
local access_num, err = red:incr("access_" .. ngx.var.remote_addr)
if (not access_num or access_num >= 10) then
ngx.var.my_nginx_var = "deny"
return
end
ngx.var.my_nginx_var = "allow"
red:expire("access_" .. ngx.var.remote_addr, 16*3600)
}
}
}
Is your feature request related to a problem? Please describe. If one uses openresty, there is a possibility to include Lua-Scripts into the config file with
access_by_lua_block {}
(and others). Those parts are parsed as default nginx-config.Describe the solution you'd like It would be great if the plugin would realize a language injection (or allow them with a comment or similar) and would disable nginx-language checks and - ideally - highlight the injected language (with Lua-Plugin installed). Currently, the last line of a lua_block is always considered syntactically incorrect, because of the missing
;
.Describe alternatives you've considered Always use
_lua_by_file
directives and external lua files that get correctly highlighted if the Lua-Plugin is installed.Additional context Full List of directives from lua-nginx-module:
string based (discouraged; I would not implement this, but if it does not take much additional work, it's a nive-to-have)
block based
Reduced config example: