Description
Is your feature request related to a problem? Please describe
This is mostly a feature request because it's related to openresty which adds additional directives to the nginx configuration, and I'm not sure that's a core concern for this organisation.
When using *_by_lua_bock
directives the parser seems to get confused and adds configuration outside the block into the lua block.
Example config
header_filter_by_lua_block {
cors_allow_for([[some\.domain\.name$]])
}
include includes/common;
This generates JSON which looks like
...
{
"directive": "header_filter_by_lua_block",
"line": 32,
"args": [],
"block": [
{
"directive": "cors_allow_for([[some\\.domain\\.name$]])",
"line": 33,
"args": []
},
{
"directive": "error_page",
"line": 2,
"args": [
"404",
"=",
"@error"
]
},
{
...
where the error_page
directive and subsequent directives come from the included file.
Describe the solution you'd like
To get a valid representation of the configuration. The approach suggested here is to identify specific directives to exclude them from further parsing. This means the offending directive will still appear in the output, but its block will be empty. If these directives could be identified by command line options then the solution would work for as-yet unforeseen directives.
Describe alternatives you've considered
Fixing the parser to correctly process the *_by_lua_block
directives (probably by turning them into strings). I don't think this is a great option because any nginx addon could add a directive which could fall afoul of the same issue.
Additional context
Add any other context or screenshots about the feature request here.