Adding Custom Nginx Config variables with set


#1

Is it possible at this time to set variables in the server block without having to directly modify nginx-kong.conf? I imagine it would be similar to this: https://docs.konghq.com/0.14.x/configuration/#injecting-individual-nginx-directives

For example, I’m using a docker-compose.yml file and I can do the following:

environment:
  KONG_NGINX_HTTP_LUA_CODE_CACHE: "off" # evaluates to `lua_code_cache: off;` in http block

but I cannot set a variable in the server block like this:

environment:
  KONG_NGINX_PROXY_SET_$SESSION_SECRET: "secret"

Because this evaluates to set_$session_secret: secret instead of set $session_secret: secret;

I imagine this is probably a shortcoming to the way this functionality works… just wanted to verify it isn’t a user error before I move forward into a method that requires a completely custom nginx-kong.conf file.

I am debugging and currently trying to accomplish this: https://github.com/bungle/lua-resty-session#notes-about-turning-lua-code-cache-off


#2

@jerney Did you try doing the following?

environment:
 KONG_NGINX_PROXY_SET="$session_secret: secret"

This should render the following line inside the proxy server block:
set $session_secret: secret;