Following these instructions https://github.com/nginx/docker-nginx/tree/4bf0763f4977fff7e9648add59e0540088f3ca9f/modules
...which are linked from here: https://github.com/nginx/docker-nginx/tree/master/modules
...entitled "Adding third-party modules to nginx official image"
The build relies on source available here: https://hg.nginx.org/pkg-oss
The hg repository doesn't have latest nginx. It seems to stop at 1.26.
So you cannot build 1.27 or later this way.
If you want that, maybe follow the instructions for "Docker BuildKit", here:
https://github.com/nginx/docker-nginx/tree/master/modules
cd make-containers
docker build --build-arg ENABLED_MODULES="ndk lua"
-f Dockerfile.alpine
--build-arg NGINX_FROM_IMAGE=nginx:1.26.2-alpine
-t my-nginx-1.26-with-lua .
docker build --build-arg ENABLED_MODULES="ndk lua"
-f Dockerfile.alpine
--build-arg NGINX_FROM_IMAGE=nginx:1.20.2-alpine
-t my-nginx-1.20-with-lua .
This worked. At the end of each build there is a notice
The 3rd-party Lua dynamic modules for nginx have been installed.
To enable these modules, add the following to /etc/nginx/nginx.conf
and reload nginx:
load_module modules/ndk_http_module.so;
load_module modules/ngx_http_lua_module.so;
load_module modules/ngx_stream_lua_module.so;
Note that ndk_http_module.so must be placed first.
These modules are compiled with LuaJIT 2.1 library.
The following binary should be used for testing and bytecode generation:
/usr/bin/nginx-luajit
Please refer to the modules documentation for further details:
https://github.com/openresty/lua-nginx-module
https://github.com/openresty/stream-lua-nginx-module
To run:
podman run --rm --name nginx-1.20
-p 8081:8080
-v "$(pwd)/nginx-3.conf:/etc/nginx/nginx.conf"
my-nginx-1.20-with-lua
See the other file for my nginx.conf