I'm customizing the ingress-nginx controller by using a modified nginx-base image. Specifically, I want to add the NJS module to enable advanced CORS handling logic via js_import and js_header_filter directives.
I build my own nginx-base image based on registry.k8s.io/ingress-nginx/nginx:v1.2.1, only added the NJS module.
Source: /
Built from the helm-chart-4.12.1 branch The issue
When I use the custom base image and enable my custom CORS logic via http-snippet in the HelmRelease config:
config:
http-snippet: |
include /etc/nginx/CORS_http.conf;
cat /etc/nginx/CORS_http.conf
js_var $cors_config_file; # set or override in server or location contexts of nginx configuration to point to configuration file
js_var $cors_is_valid_preflight_request; # set by cors.header_filter to signal detection of a valid pre-flight request
js_import cors from /etc/nginx/njs/http/cors.js;
I get the following error: failed to load the 'resty.core' module
2025/03/31 09:41:20 [alert] 18#18: failed to load the 'resty.core' module (); ensure you are using an OpenResty release from .html (reason: module 'resty.core' not found:
no field package.preload['resty.core']
no file '/etc/nginx/lua/resty/core.lua'
no file '../lua-resty-core/lib/resty/core.lua'
no file '../lua-resty-lrucache/lib/resty/core.lua'
no file './resty/core.lua'
no file '/usr/local/share/luajit-2.1/resty/core.lua'
no file '/usr/local/share/lua/5.1/resty/core.lua'
no file '/usr/local/share/lua/5.1/resty/core/init.lua'
Which seems unrelated to my CORS config or NJS module.
This error disappears when I comment out the http-snippet. But the snippet itself only references js_import (NJS), and does not use Lua at all.
It seems like enabling NJS somehow triggers Lua module loading even when Lua isn't used.
Also tried building from main, from branches starting with controller v1.12.0 down to v1.10.0, and from helm-chart-4.12.1 down to helm-chart-4.10.0 - same result every time. Tried both building manually and using the current ci.yaml from a fork of the ingress-nginx repo.
Thanks.