From 4a42c8f249feff418995517ef6823194654f5e7b Mon Sep 17 00:00:00 2001 From: Harry Bagdi Date: Mon, 11 Jun 2018 12:41:58 -0700 Subject: [PATCH 1/4] feat(conf) add support to configure nginx directives via kong.conf Problem ------- Kong ships with an NGINX template which is rendered when Kong starts. There exists no mechanisms to add/update any NGINX directive to the `nginx.conf` used to run Kong. To change or add any directive, user has to use a custom NGINX template which has to be synced with Kong for a release which introduces changes to Kong's template. Including options in `kong.conf` to configure NGINX directives is not a good solution since the list will be endless. This problem can be seen in #3010, #3323 and #3382. Solution -------- There needs to be a flexible way to specify any NGINX directive via Kong's config file without Kong needing to maintain a list of all NGINX directives. While a clean and ideal solution would be #2355, this commit adopts a simpler as discussed like the one proposed in #2675. NGINX directives can be specified using config variables with prefixes, which help determine the block in which to place a directive. eg: `nginx_proxy_add_header=Header-Name header-value` will add a `add_header Header-Name header-value;` directive in the proxy server block of Kong. `nginx_http_lua_shared_dict=custom_cache 2k` will add a a `lua_shared_dict custom_cache 2k;` directive to HTTP block of Kong.s --- kong-0.13.1-0.rockspec | 1 + kong/cmd/utils/env.lua | 33 +++++++++ kong/cmd/utils/nginx_signals.lua | 19 +++++ kong/cmd/utils/prefix_handler.lua | 11 ++- kong/conf_loader.lua | 74 ++++++++++++++++++- kong/init.lua | 7 ++ kong/templates/nginx_kong.lua | 12 +++ spec/01-unit/002-conf_loader_spec.lua | 25 ++++++- spec/01-unit/003-prefix_handler_spec.lua | 2 +- .../02-integration/02-cmd/09-prepare_spec.lua | 6 ++ .../14-custom_nginx_directive_spec.lua | 58 +++++++++++++++ spec/fixtures/custom_nginx.template | 12 +++ spec/fixtures/invalid_nginx_directives.conf | 1 + spec/fixtures/nginx-directives.conf | 2 + 14 files changed, 258 insertions(+), 5 deletions(-) create mode 100644 kong/cmd/utils/env.lua create mode 100644 spec/02-integration/05-proxy/14-custom_nginx_directive_spec.lua create mode 100644 spec/fixtures/invalid_nginx_directives.conf create mode 100644 spec/fixtures/nginx-directives.conf diff --git a/kong-0.13.1-0.rockspec b/kong-0.13.1-0.rockspec index 8cc8992e151..9e56e7bb72b 100644 --- a/kong-0.13.1-0.rockspec +++ b/kong-0.13.1-0.rockspec @@ -76,6 +76,7 @@ build = { ["kong.cmd.version"] = "kong/cmd/version.lua", ["kong.cmd.utils.log"] = "kong/cmd/utils/log.lua", ["kong.cmd.utils.kill"] = "kong/cmd/utils/kill.lua", + ["kong.cmd.utils.env"] = "kong/cmd/utils/env.lua", ["kong.cmd.utils.nginx_signals"] = "kong/cmd/utils/nginx_signals.lua", ["kong.cmd.utils.prefix_handler"] = "kong/cmd/utils/prefix_handler.lua", diff --git a/kong/cmd/utils/env.lua b/kong/cmd/utils/env.lua new file mode 100644 index 00000000000..a22e9017219 --- /dev/null +++ b/kong/cmd/utils/env.lua @@ -0,0 +1,33 @@ +local pl_utils = require "pl.utils" +local log = require "kong.cmd.utils.log" +local fmt = string.format + + +local cmd = [[ printenv ]] + + +-- returns table and err +local function read_all() + log.debug("reading environment variables: %s", cmd) + local vars = {} + local success, ret_code, stdout, stderr = pl_utils.executeex(cmd) + if not success or ret_code ~= 0 then + return nil, fmt("could not read environment variables (exit code: %d): %s", + ret_code, stderr) + end + + for line in stdout:gmatch("[^\r\n]+") do + local i = string.find(line, "=") -- match first = + local k = string.sub(line,1, i-1) + local v = string.sub(line, i+1) + if k and v then + vars[k] = v + end + end + return vars +end + + +return { + read_all = read_all, +} diff --git a/kong/cmd/utils/nginx_signals.lua b/kong/cmd/utils/nginx_signals.lua index f414c911ad9..ffb6da8a0d3 100644 --- a/kong/cmd/utils/nginx_signals.lua +++ b/kong/cmd/utils/nginx_signals.lua @@ -107,6 +107,25 @@ function _M.start(kong_conf) return true end +function _M.check_conf(kong_conf) + local nginx_bin, err = _M.find_nginx_bin() + if not nginx_bin then + return nil, err + end + + local cmd = fmt("KONG_NGINX_CONF_CHECK=true %s -t -p %s -c %s", + nginx_bin, kong_conf.prefix, "nginx.conf") + log.debug("checking nginx conf: %s", cmd) + + local ok, retcode, _, stderr = pl_utils.executeex(cmd) + if not ok then + return false, ("failed to validate nginx configuration " .. + "(exit code %d):\n%s"):format(retcode ,stderr) + end + + return true +end + function _M.stop(kong_conf) return send_signal(kong_conf, "TERM") end diff --git a/kong/cmd/utils/prefix_handler.lua b/kong/cmd/utils/prefix_handler.lua index 3b7a9d26cb2..08fe8f6cb1f 100644 --- a/kong/cmd/utils/prefix_handler.lua +++ b/kong/cmd/utils/prefix_handler.lua @@ -13,6 +13,7 @@ local log = require "kong.cmd.utils.log" local constants = require "kong.constants" local ffi = require "ffi" local fmt = string.format +local nginx_signals = require "kong.cmd.utils.nginx_signals" local function gen_default_ssl_cert(kong_config, admin) -- create SSL folder @@ -194,8 +195,8 @@ local function prepare_prefix(kong_config, nginx_custom_template_path) return nil, err end end - if not pl_path.exists(kong_config.nginx_admin_acc_logs) then - local ok, err = pl_file.write(kong_config.nginx_admin_acc_logs, "") + if not pl_path.exists(kong_config.admin_acc_logs) then + local ok, err = pl_file.write(kong_config.admin_acc_logs, "") if not ok then return nil, err end @@ -254,6 +255,12 @@ local function prepare_prefix(kong_config, nginx_custom_template_path) end pl_file.write(kong_config.nginx_kong_conf, nginx_kong_conf) + -- check if nginx conf is valid + local _, err = nginx_signals.check_conf(kong_config) + if err then + return nil, err + end + -- write kong.conf in prefix (for workers and CLI) local buf = { "# *************************", diff --git a/kong/conf_loader.lua b/kong/conf_loader.lua index 5adabeb16b7..96774211508 100644 --- a/kong/conf_loader.lua +++ b/kong/conf_loader.lua @@ -9,6 +9,7 @@ local pl_path = require "pl.path" local tablex = require "pl.tablex" local utils = require "kong.tools.utils" local log = require "kong.cmd.utils.log" +local env = require "kong.cmd.utils.env" local ip = require "kong.tools.ip" local ciphers = require "kong.tools.ciphers" @@ -28,11 +29,17 @@ local header_key_to_name = { [string.lower(headers.UPSTREAM_STATUS)] = headers.UPSTREAM_STATUS, } +local CONF_KEY_PREFIXES = { + ["nginx_http_directives"] = "nginx_http_", + ["nginx_proxy_directives"] = "nginx_proxy_", + ["nginx_admin_directives"] = "nginx_admin_", +} + local PREFIX_PATHS = { nginx_pid = {"pids", "nginx.pid"}, nginx_err_logs = {"logs", "error.log"}, nginx_acc_logs = {"logs", "access.log"}, - nginx_admin_acc_logs = {"logs", "admin_access.log"}, + admin_acc_logs = {"logs", "admin_access.log"}, nginx_conf = {"nginx.conf"}, nginx_kong_conf = {"nginx-kong.conf"} ; @@ -448,6 +455,24 @@ local function parse_listeners(values) return list end +local function parse_nginx_directives(prefix, conf) + local directives = {} + + if type(prefix) ~= "string" or type(conf) ~= "table" then + return directives + end + + for k, v in pairs(conf) do + if type(k) == "string" then + local _ , _ , directive= string.find(k, prefix .. "(.+)") + if directive then + directives[directive] = v + end + end + end + return directives +end + --- Load Kong configuration -- The loaded configuration will have all properties from the default config -- merged with the (optionally) specified config file, environment variables @@ -514,6 +539,48 @@ local function load(path, custom_conf) -- Merging & validation ----------------------- + -- find dynamic keys that need to be loaded + do + local dynamic_keys = {} + local function find_dynamic_keys(t, prefix) + if not t then + return + end + + for k, v in pairs(t) do + local _, _, directive = string.find(k, "(" .. prefix .. ".+)") + if directive then + dynamic_keys[directive] = true + if tonumber(v) then + t[k] = string.format("%q", v) + end + end + end + end + + local env_vars, err = env.read_all() + if err then + return nil, err + end + + local kong_env_vars = {} + for k, v in pairs(env_vars) do + local clean_k = string.lower(k) + local kong_var = string.match(clean_k, "^kong_(.+)") + if kong_var then + kong_env_vars[kong_var] = true + end + end + + for _, prefix in pairs(CONF_KEY_PREFIXES) do + find_dynamic_keys(custom_conf, prefix) + find_dynamic_keys(kong_env_vars, prefix) + find_dynamic_keys(from_file_conf, prefix) + end + + defaults = tablex.merge(defaults, dynamic_keys, true) + end + -- merge default conf with file conf, ENV variables and arg conf (with precedence) local conf = tablex.pairmap(overrides, defaults, from_file_conf, custom_conf) @@ -525,6 +592,11 @@ local function load(path, custom_conf) conf = tablex.merge(conf, defaults) -- intersection (remove extraneous properties) + -- nginx directives from conf + for block, prefix in pairs(CONF_KEY_PREFIXES) do + conf[block] = parse_nginx_directives(prefix, conf) + end + -- print alphabetically-sorted values do local conf_arr = {} diff --git a/kong/init.lua b/kong/init.lua index 540c2084af8..de3f36026c9 100644 --- a/kong/init.lua +++ b/kong/init.lua @@ -29,6 +29,13 @@ require "resty.core" local constants = require "kong.constants" do + -- if we're running nginx -t then don't initialize + if os.getenv("KONG_NGINX_CONF_CHECK") then + return { + init = function() + end, + } + end -- let's ensure the required shared dictionaries are -- declared via lua_shared_dict in the Nginx conf diff --git a/kong/templates/nginx_kong.lua b/kong/templates/nginx_kong.lua index a66c230fe4d..53efecff83c 100644 --- a/kong/templates/nginx_kong.lua +++ b/kong/templates/nginx_kong.lua @@ -44,6 +44,10 @@ lua_ssl_trusted_certificate '${{LUA_SSL_TRUSTED_CERTIFICATE}}'; lua_ssl_verify_depth ${{LUA_SSL_VERIFY_DEPTH}}; > end +> for k, v in pairs(nginx_http_directives) do + $(k) $(v); +> end + init_by_lua_block { kong = require 'kong' kong.init() @@ -101,6 +105,10 @@ server { set_real_ip_from $(trusted_ips[i]); > end +> for k, v in pairs(nginx_proxy_directives) do + $(k) $(v); +> end + location / { set $upstream_host ''; set $upstream_upgrade ''; @@ -180,6 +188,10 @@ server { ssl_ciphers ${{SSL_CIPHERS}}; > end +> for k, v in pairs(nginx_admin_directives) do + $(k) $(v); +> end + location / { default_type application/json; content_by_lua_block { diff --git a/spec/01-unit/002-conf_loader_spec.lua b/spec/01-unit/002-conf_loader_spec.lua index 1db6f577877..b0694d447ad 100644 --- a/spec/01-unit/002-conf_loader_spec.lua +++ b/spec/01-unit/002-conf_loader_spec.lua @@ -143,7 +143,7 @@ describe("Configuration loader", function() assert.equal("/usr/local/kong/pids/nginx.pid", conf.nginx_pid) assert.equal("/usr/local/kong/logs/error.log", conf.nginx_err_logs) assert.equal("/usr/local/kong/logs/access.log", conf.nginx_acc_logs) - assert.equal("/usr/local/kong/logs/admin_access.log", conf.nginx_admin_acc_logs) + assert.equal("/usr/local/kong/logs/admin_access.log", conf.admin_acc_logs) assert.equal("/usr/local/kong/nginx.conf", conf.nginx_conf) assert.equal("/usr/local/kong/nginx-kong.conf", conf.nginx_kong_conf) assert.equal("/usr/local/kong/.kong_env", conf.kong_env) @@ -170,6 +170,29 @@ describe("Configuration loader", function() local conf = assert(conf_loader("spec/fixtures/to-strip.conf")) assert.equal("test#123", conf.pg_password) end) + it("loads flexible prefix based configs from a file", function() + local conf = assert(conf_loader("spec/fixtures/nginx-directives.conf", nil)) + assert.equal("custom_cache 5m", + conf.nginx_http_directives["lua_shared_dict"]) + assert.equal("8 24k", + conf.nginx_http_directives["large_client_header_buffers"]) + end) + it("quotes numeric flexible prefix based configs", function() + local conf = assert(conf_loader(nil, { + ["nginx_http_max_pending_timers"] = 4096, + })) + assert.equal("\"4096\"", conf.nginx_http_directives["max_pending_timers"]) + end) + it("accepts flexible config values with highest precedence", function() + local conf = assert(conf_loader("spec/fixtures/nginx-directives.conf", { + ["nginx_http_large_client_header_buffers"] = "4 16k", + ["nginx_http_lua_shared_dict"] = "custom_cache 2m", + })) + assert.equal("custom_cache 2m", + conf.nginx_http_directives["lua_shared_dict"]) + assert.equal("4 16k", + conf.nginx_http_directives["large_client_header_buffers"]) + end) describe("nginx_user", function() it("is nil by default", function() diff --git a/spec/01-unit/003-prefix_handler_spec.lua b/spec/01-unit/003-prefix_handler_spec.lua index 7ea74d435ab..c2ecbabb53b 100644 --- a/spec/01-unit/003-prefix_handler_spec.lua +++ b/spec/01-unit/003-prefix_handler_spec.lua @@ -379,7 +379,7 @@ describe("NGINX conf compiler", function() assert.truthy(exists(tmp_config.nginx_kong_conf)) assert.truthy(exists(tmp_config.nginx_err_logs)) assert.truthy(exists(tmp_config.nginx_acc_logs)) - assert.truthy(exists(tmp_config.nginx_admin_acc_logs)) + assert.truthy(exists(tmp_config.admin_acc_logs)) end) it("dumps Kong conf", function() assert(prefix_handler.prepare_prefix(tmp_config)) diff --git a/spec/02-integration/02-cmd/09-prepare_spec.lua b/spec/02-integration/02-cmd/09-prepare_spec.lua index d2ed884a802..1afa2947f07 100644 --- a/spec/02-integration/02-cmd/09-prepare_spec.lua +++ b/spec/02-integration/02-cmd/09-prepare_spec.lua @@ -45,5 +45,11 @@ describe("kong prepare", function() assert.is_string(stderr) assert.matches("Error: no file at: foobar.conf", stderr, nil, true) end) + it("on invalid nginx directive", function() + local ok, stderr = helpers.kong_exec "prepare --conf spec/fixtures/invalid_nginx_directives.conf" + assert.False(ok) + assert.is_string(stderr) + assert.matches("[emerg] unknown directive \"random_directive\"", stderr, nil, true) + end) end) end) diff --git a/spec/02-integration/05-proxy/14-custom_nginx_directive_spec.lua b/spec/02-integration/05-proxy/14-custom_nginx_directive_spec.lua new file mode 100644 index 00000000000..1b4013f5b89 --- /dev/null +++ b/spec/02-integration/05-proxy/14-custom_nginx_directive_spec.lua @@ -0,0 +1,58 @@ +local helpers = require "spec.helpers" + + +describe("Custom NGINX directives", function() + local proxy_client + local bp + + local function start(config) + return function() + bp.routes:insert { + hosts = { "headers-inspect.com" }, + } + + config = config or {} + config.nginx_conf = "spec/fixtures/custom_nginx.template" + + assert(helpers.start_kong(config)) + end + end + + setup(function() + bp = helpers.get_db_utils() + end) + + before_each(function() + proxy_client = helpers.proxy_client() + end) + + after_each(function() + if proxy_client then + proxy_client:close() + end + end) + + describe("with config value 'nginx_proxy_add_header=foo-header bar-value'", function() + + setup(start{ + ["nginx_proxy_add_header"] = "foo-header bar-value" + }) + + teardown(helpers.stop_kong) + + it("header 'foo-header' should be inserted", function() + local res = assert(proxy_client:send { + method = "GET", + path = "/get", + headers = { + host = "headers-inspect.com", + } + }) + + assert.res_status(200, res) + assert.equal("bar-value", res.headers["foo-header"]) + end) + + end) +end) + diff --git a/spec/fixtures/custom_nginx.template b/spec/fixtures/custom_nginx.template index a19bee4f031..9bbd39ed720 100644 --- a/spec/fixtures/custom_nginx.template +++ b/spec/fixtures/custom_nginx.template @@ -57,6 +57,10 @@ http { lua_ssl_verify_depth ${{LUA_SSL_VERIFY_DEPTH}}; > end +> for k, v in pairs(nginx_http_directives) do + $(k) $(v); +> end + init_by_lua_block { kong = require 'kong' kong.init() @@ -102,6 +106,10 @@ http { set_real_ip_from $(trusted_ips[i]); > end +> for k, v in pairs(nginx_proxy_directives) do + $(k) $(v); +> end + location / { default_type ''; @@ -177,6 +185,10 @@ http { ssl_protocols TLSv1.1 TLSv1.2; > end +> for k, v in pairs(nginx_admin_directives) do + $(k) $(v); +> end + location / { default_type application/json; content_by_lua_block { diff --git a/spec/fixtures/invalid_nginx_directives.conf b/spec/fixtures/invalid_nginx_directives.conf new file mode 100644 index 00000000000..81a46aeabed --- /dev/null +++ b/spec/fixtures/invalid_nginx_directives.conf @@ -0,0 +1 @@ +nginx_http_random_directive=value diff --git a/spec/fixtures/nginx-directives.conf b/spec/fixtures/nginx-directives.conf new file mode 100644 index 00000000000..5598639804f --- /dev/null +++ b/spec/fixtures/nginx-directives.conf @@ -0,0 +1,2 @@ +nginx_http_large_client_header_buffers=8 24k +nginx_http_lua_shared_dict=custom_cache 5m From 392e20341eeee84074cffe441fc9a2e17db59477 Mon Sep 17 00:00:00 2001 From: Harry Bagdi Date: Mon, 11 Jun 2018 13:38:06 -0700 Subject: [PATCH 2/4] [squash] fix environment read Signed-off-by: Harry Bagdi --- kong/cmd/utils/env.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kong/cmd/utils/env.lua b/kong/cmd/utils/env.lua index a22e9017219..a69b2dad079 100644 --- a/kong/cmd/utils/env.lua +++ b/kong/cmd/utils/env.lua @@ -18,10 +18,12 @@ local function read_all() for line in stdout:gmatch("[^\r\n]+") do local i = string.find(line, "=") -- match first = - local k = string.sub(line,1, i-1) - local v = string.sub(line, i+1) - if k and v then - vars[k] = v + if i then + local k = string.sub(line,1, i-1) + local v = string.sub(line, i+1) + if k and v then + vars[k] = v + end end end return vars From 659bbb66fb919f0db17b8fbecfa479f3e420c9e9 Mon Sep 17 00:00:00 2001 From: Harry Bagdi Date: Mon, 11 Jun 2018 15:15:58 -0700 Subject: [PATCH 3/4] [squash] specify prefix in test case and rename file Signed-off-by: Harry Bagdi --- spec/02-integration/02-cmd/09-prepare_spec.lua | 3 ++- ...x_directive_spec.lua => 15-custom_nginx_directive_spec.lua} | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename spec/02-integration/05-proxy/{14-custom_nginx_directive_spec.lua => 15-custom_nginx_directive_spec.lua} (100%) diff --git a/spec/02-integration/02-cmd/09-prepare_spec.lua b/spec/02-integration/02-cmd/09-prepare_spec.lua index 1afa2947f07..83adab2fafa 100644 --- a/spec/02-integration/02-cmd/09-prepare_spec.lua +++ b/spec/02-integration/02-cmd/09-prepare_spec.lua @@ -46,7 +46,8 @@ describe("kong prepare", function() assert.matches("Error: no file at: foobar.conf", stderr, nil, true) end) it("on invalid nginx directive", function() - local ok, stderr = helpers.kong_exec "prepare --conf spec/fixtures/invalid_nginx_directives.conf" + local ok, stderr = helpers.kong_exec("prepare --conf spec/fixtures/invalid_nginx_directives.conf" .. + " -p " .. TEST_PREFIX) assert.False(ok) assert.is_string(stderr) assert.matches("[emerg] unknown directive \"random_directive\"", stderr, nil, true) diff --git a/spec/02-integration/05-proxy/14-custom_nginx_directive_spec.lua b/spec/02-integration/05-proxy/15-custom_nginx_directive_spec.lua similarity index 100% rename from spec/02-integration/05-proxy/14-custom_nginx_directive_spec.lua rename to spec/02-integration/05-proxy/15-custom_nginx_directive_spec.lua From 2317d42baf56f9198ef2eac12f376f1bbd588ca2 Mon Sep 17 00:00:00 2001 From: Harry Bagdi Date: Mon, 11 Jun 2018 17:16:10 -0700 Subject: [PATCH 4/4] [squash] check for shms, style and add comment Signed-off-by: Harry Bagdi --- kong/cmd/utils/env.lua | 6 +++--- kong/cmd/utils/nginx_signals.lua | 2 +- kong/conf_loader.lua | 4 +++- kong/init.lua | 15 ++++++++------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/kong/cmd/utils/env.lua b/kong/cmd/utils/env.lua index a69b2dad079..0f639d62ce0 100644 --- a/kong/cmd/utils/env.lua +++ b/kong/cmd/utils/env.lua @@ -13,14 +13,14 @@ local function read_all() local success, ret_code, stdout, stderr = pl_utils.executeex(cmd) if not success or ret_code ~= 0 then return nil, fmt("could not read environment variables (exit code: %d): %s", - ret_code, stderr) + ret_code, stderr) end for line in stdout:gmatch("[^\r\n]+") do local i = string.find(line, "=") -- match first = if i then - local k = string.sub(line,1, i-1) - local v = string.sub(line, i+1) + local k = string.sub(line, 1, i - 1) + local v = string.sub(line, i + 1) if k and v then vars[k] = v end diff --git a/kong/cmd/utils/nginx_signals.lua b/kong/cmd/utils/nginx_signals.lua index ffb6da8a0d3..94be9f9ed8e 100644 --- a/kong/cmd/utils/nginx_signals.lua +++ b/kong/cmd/utils/nginx_signals.lua @@ -120,7 +120,7 @@ function _M.check_conf(kong_conf) local ok, retcode, _, stderr = pl_utils.executeex(cmd) if not ok then return false, ("failed to validate nginx configuration " .. - "(exit code %d):\n%s"):format(retcode ,stderr) + "(exit code %d):\n%s"):format(retcode, stderr) end return true diff --git a/kong/conf_loader.lua b/kong/conf_loader.lua index 96774211508..3971985720a 100644 --- a/kong/conf_loader.lua +++ b/kong/conf_loader.lua @@ -464,7 +464,7 @@ local function parse_nginx_directives(prefix, conf) for k, v in pairs(conf) do if type(k) == "string" then - local _ , _ , directive= string.find(k, prefix .. "(.+)") + local _, _, directive= string.find(k, prefix .. "(.+)") if directive then directives[directive] = v end @@ -578,6 +578,8 @@ local function load(path, custom_conf) find_dynamic_keys(from_file_conf, prefix) end + -- union (add dynamic keys to `defaults` to prevent removal of the keys + -- during the intersection that happens later) defaults = tablex.merge(defaults, dynamic_keys, true) end diff --git a/kong/init.lua b/kong/init.lua index de3f36026c9..e0c5360a227 100644 --- a/kong/init.lua +++ b/kong/init.lua @@ -29,13 +29,6 @@ require "resty.core" local constants = require "kong.constants" do - -- if we're running nginx -t then don't initialize - if os.getenv("KONG_NGINX_CONF_CHECK") then - return { - init = function() - end, - } - end -- let's ensure the required shared dictionaries are -- declared via lua_shared_dict in the Nginx conf @@ -47,6 +40,14 @@ do "directive is defined.") end end + + -- if we're running nginx -t then don't initialize + if os.getenv("KONG_NGINX_CONF_CHECK") then + return { + init = function() + end, + } + end end require("kong.globalpatches")()