diff --git a/gateway/conf/nginx.conf.liquid b/gateway/conf/nginx.conf.liquid index 2ad5bcf9a..9c29608ea 100644 --- a/gateway/conf/nginx.conf.liquid +++ b/gateway/conf/nginx.conf.liquid @@ -60,14 +60,21 @@ http { resolver {{ nameservers | join: " " }}; {% endif %} + {%- comment -%} +Capture environment variables for init.conf, excluding APICAST_SERVICES_LIST which can be +very large and hit NGINX parser limits. APICAST_SERVICES_LIST is cached separately in +init.conf using os.getenv() during init phase before the environment is cleared. + {%- endcomment -%} {%- capture ENV -%} - { - {%- for env in env -%} - {%- if env.name | starts_with: 'APICAST_', 'THREESCALE_' %} - [ [[{{ env.name }}]] ] = [[{{ env.value }}]], - {%- endif -%} + { + {%- for env in env -%} + {%- if env.name | starts_with: 'APICAST_', 'THREESCALE_' %} + {%- unless env.name == 'APICAST_SERVICES_LIST' %} + [ [[{{ env.name }}]] ] = [[{{ env.value }}]], + {%- endunless -%} + {%- endif -%} {%- endfor %} - } + } {%- endcapture -%} {% for file in "http.d/*.conf" | filesystem %} diff --git a/gateway/http.d/init.conf b/gateway/http.d/init.conf index 55a8764ce..1cf48ac7c 100644 --- a/gateway/http.d/init.conf +++ b/gateway/http.d/init.conf @@ -58,6 +58,11 @@ init_by_lua_block { end end + local services_list = os.getenv('APICAST_SERVICES_LIST') + if services_list and not resty_env.value('APICAST_SERVICES_LIST') then + resty_env.set('APICAST_SERVICES_LIST', services_list) + end + require('resty.resolver').init() require('apicast.loader')