openresty / docker-openresty

Docker tooling for OpenResty
https://hub.docker.com/r/openresty/openresty
BSD 2-Clause "Simplified" License
935 stars 525 forks source link

ndk_http_module.so module missing from docker containers #215

Open hakenmt opened 1 year ago

hakenmt commented 1 year ago

I'm using the docker image openresty/openresty:alpine. I'm copying a custom nginx conf file to the image during a build.

Dockerfile

FROM openresty/openresty:1.21.4.1-1-alpine

COPY nginx.conf /etc/nginx/conf.d/

EXPOSE 80

And this is my conf file

pcre_jit on;
worker_processes 1;

events {
    worker_connections  1024;
}

http {
  include       /usr/local/openresty/nginx/conf/mime.types;
  default_type text/plain;

  server {
    listen                              80;
    location / {     
      content_by_lua '
        ngx.say("<p>hello nginx</p>")
      ';     
    }
  }
}

I get an error trying to run the container,

[emerg] dlopen() "/usr/local/openresty/nginx/modules/ndk_http_module.so" failed (Error loading shared library /usr/local/openresty/nginx/modules/ndk_http_module.so: No such file or directory) in /usr/local/openresty/nginx/conf/nginx.conf:1

I feel like I'm following the basic getting started instructions, so not sure what is wrong with the conf file I'm providing.

Update: I built an image without copying my config file so I could login to the container, listing the modules directory, I get this:

ls /usr/local/openresty/nginx/modules/
ngx_http_geoip_module.so         ngx_http_xslt_filter_module.so
ngx_http_image_filter_module.so

So it looks like the Lua modules aren't placed there? Where should they be?

Update 2: Do I need to install the modules myself? From reading all of the openresty documentation, I was under the impression that everything was already bundled into the build and that wouldn't be necessary.

neomantra commented 1 year ago

@hakenmt Sorry to just get to this now. [Also, I don't think I got notifications of your update edits vs new comments]

I couldn't reproduce your problem (with respect to ndk), but I can show you how to get your sample working:

file: test.conf

server {
  listen 80;
  location / {     
    content_by_lua '
      ngx.say("<p>hello nginx</p>")
    ';     
  }
}

invocation:

docker run --rm -d -p 8420:80 -v $(pwd)/test.conf:/etc/nginx/conf.d/default.conf:ro openresty/openresty:alpine

test:

> curl localhost:8420
<p>hello nginx</p>

You don't see many modules when you search because they are compiled into OpenResty's nginx executable. You can find Lua files here: /usr/local/openresty/lualib

The documentation could use some love to show how to do this straight-forward example. Otherwise, it's very geared to people setting up their own images, rather than using them.

Try that out and if you have more issues, feel free to continue commenting on this issue.