kubernetes-ingress icon indicating copy to clipboard operation
kubernetes-ingress copied to clipboard

dlopen() "/etc/nginx/modules/ngx_http_js_module.so" failed (/etc/nginx/modules/ngx_http_js_module.so: cannot open shared object file: No such file or directory

Open nivedithahariharan opened this issue 1 year ago • 7 comments

I am currently upgrading to kubernetes-ingress_3.6.1_linux_amd64.tar.gz. I installed the corresponding NGINX binary from https://nginx.org/packages/mainline/centos/9/x86_64/RPMS/. The kubernetes I am using is Linux CentOS 7 K3s v1.25. I am creating my own docker image on top of UBI9.

This always worked for me, but in this upgrade we see the following error when Nginx pod comes up and crashes:

dlopen() "/etc/nginx/modules/ngx_http_js_module.so" failed (/etc/nginx/modules/ngx_http_js_module.so: cannot open shared object file: No such file or directory) in /etc/nginx/nginx.conf:8

This is due to the following line that was added in last few versions: https://github.com/nginxinc/kubernetes-ingress/blob/v3.6.1/internal/configs/version1/nginx.tmpl#L23 : load_module modules/ngx_http_js_module.so;

Is this module used somewhere in NGINX, i.e do we need to load this module? If yes, can you please provide me steps or point me to the documentation?

Update : After installing nginx-module-njs-1.27.0+0.8.5-2.el9.ngx.x86_64.rpm this error is gone. But I do see the following error now: [emerg] 25#25: SyntaxError: Cannot find module "/etc/nginx/njs/apikey_auth.js" in /etc/nginx/:1

Thanks in advance

nivedithahariharan avatar Jul 17 '24 17:07 nivedithahariharan

Hi @nivedithahariharan thanks for reporting!

Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this :slightly_smiling_face:

Cheers!

github-actions[bot] avatar Jul 17 '24 17:07 github-actions[bot]

Hi @nivedithahariharan this module is required for apikey_auth functionality added in NIC v3.6.0 and will be used for some further enhancements in later releases as well. I'd recommend building using make command, see https://docs.nginx.com/nginx-ingress-controller/installation/building-nginx-ingress-controller/#key-makefile-targets eg: make ubi-image PREFIX=nginx-ingress TARGET=download or make ubi-image PREFIX=nginx-ingress VERSION=3.6.1

vepatel avatar Jul 18 '24 08:07 vepatel

Hi @vepatel Thanks for your suggestions. I am currently grabbing the NGINX binary rpm from https://nginx.org/packages/mainline/centos/9/x86_64/RPMS/ and installing it. When the nginx pod comes up I see that ngx_http_js_module is missing. Is there anyway I can get the module ngx_http_js_module without using the above make command

nivedithahariharan avatar Jul 18 '24 16:07 nivedithahariharan

I am building nginx ingress controller binary from source using make alpine-image PREFIX=${env.NGINX_CONTROLLER_NAME} TAG=${env.NGINX_CONTROLLER_IMAGE_TAG} VERSION=${env.RELEASE} and copying the binary into to the image. When I deploy the nginx controller to the EKS cluster, I got error

dlopen() "/etc/nginx/modules/ngx_http_js_module.so" failed (/etc/nginx/modules/ngx_http_js_module.so: cannot open shared object file: No such file or directory

After adding package nginx-mod-http-js to the base image above error got resolved and now I am getting below error 2024/07/19 00:09:09 [emerg] 18#18: SyntaxError: Cannot find module "/etc/nginx/njs/apikey_auth.js" in /etc/nginx/:1

rpodipat avatar Jul 19 '24 00:07 rpodipat

@vepatel Currently installing Update : After installing nginx-module-njs-1.27.0+0.8.5-2.el9.ngx.x86_64.rpm helps fix the issue ngx_http_js_module. Is there any easier way to get this modeule without installing nginx-module-njs rpm? Thanks

nivedithahariharan avatar Jul 22 '24 18:07 nivedithahariharan

hey @rpodipat, I built an image using

~/nginx/kubernetes-ingress on tags/v3.6.1 ● λ make alpine-image PREFIX=nginx-ingress VERSION=3.6.1-alpine

Docker version 26.0.0, build 2ae903e
go version go1.22.5 darwin/arm64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w -X main.version=3.6.1-alpine -X main.telemetryEndpoint=oss.edge.df.f5.com:443" -o nginx-ingress github.com/nginxinc/kubernetes-ingress/cmd/nginx-ingress
docker build --platform linux/amd64 --build-arg IC_VERSION=3.6.1-alpine --target local -f build/Dockerfile -t nginx-ingress:3.6.1-alpine . --build-arg BUILD_OS=alpine
[+] Building 19.4s (95/95) FINISHED 

pod log:

~/nginx/kubernetes-ingress/charts/nginx-ingress on tags/v3.6.1 ● λ klogf test-release-nginx-ingress-controller-7687b4466b-42h54 
NGINX Ingress Controller Version=3.6.1-alpine Commit=cd86e6a0ea2e2eaede1678036cea4e25f59cfa21 Date=2024-07-04T14:19:21Z DirtyState=true Arch=linux/amd64 Go=go1.22.5
I0723 09:56:06.854121       1 flags.go:321] Starting with flags: [.....]
I0723 09:56:06.866236       1 main.go:292] Kubernetes version: 1.29.6
I0723 09:56:06.909919       1 main.go:437] Using nginx version: nginx/1.27.0
2024/07/23 09:56:06 [notice] 11#11: using the "epoll" event method
2024/07/23 09:56:06 [notice] 11#11: nginx/1.27.0
2024/07/23 09:56:06 [notice] 11#11: built by gcc 13.2.1 20231014 (Alpine 13.2.1_git20231014) 
2024/07/23 09:56:06 [notice] 11#11: OS: Linux 6.1.85+
2024/07/23 09:56:06 [notice] 11#11: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/07/23 09:56:06 [notice] 11#11: start worker processes
2024/07/23 09:56:06 [notice] 11#11: start worker process 13
2024/07/23 09:56:06 [notice] 11#11: start worker process 14
I0723 09:56:06.976893       1 listener.go:56] Starting prometheus listener on: :9113/metrics
I0723 09:56:06.977895       1 leaderelection.go:250] attempting to acquire leader lease default/nginx-ingress-leader...
I0723 09:56:07.209679       1 main.go:868] Pod label updated: test-release-nginx-ingress-controller-7687b4466b-42h54
I0723 09:56:07.259761       1 leaderelection.go:260] successfully acquired lease default/nginx-ingress-leader
2024/07/23 09:56:07 [notice] 11#11: signal 1 (SIGHUP) received from 17, reconfiguring
2024/07/23 09:56:07 [notice] 11#11: reconfiguring
2024/07/23 09:56:07 [notice] 11#11: using the "epoll" event method
2024/07/23 09:56:07 [notice] 11#11: start worker processes
2024/07/23 09:56:07 [notice] 11#11: start worker process 18
2024/07/23 09:56:07 [notice] 11#11: start worker process 19
2024/07/23 09:56:07 [notice] 14#14: gracefully shutting down
2024/07/23 09:56:07 [notice] 13#13: gracefully shutting down
2024/07/23 09:56:07 [notice] 13#13: exiting
2024/07/23 09:56:07 [notice] 14#14: exiting
2024/07/23 09:56:07 [notice] 14#14: exit
2024/07/23 09:56:07 [notice] 13#13: exit
I0723 09:56:07.749817       1 event.go:377] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"default", Name:"test-release-nginx-ingress", UID:"717c4a20-b4ed-471d-a060-af468654aed6", APIVersion:"v1", ResourceVersion:"17375", FieldPath:""}): type: 'Normal' reason: 'Updated' Configuration from default/test-release-nginx-ingress was updated 

@nivedithahariharan make targets should ideally be the only way images should be built locally, have you tried the steps mentioned in https://github.com/nginxinc/kubernetes-ingress/issues/6034#issuecomment-2235960968? It should automatically pull the required modules. https://docs.nginx.com/nginx-ingress-controller/installation/building-nginx-ingress-controller/#key-makefile-targets

vepatel avatar Jul 23 '24 10:07 vepatel

@vepatel Thanks for the steps, I will give that a try!

nivedithahariharan avatar Jul 25 '24 13:07 nivedithahariharan