Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add the Lua module for nginx on Alpine linux?

I'd like to have a lean Docker image for nginx with the Lua module enabled. How can I create this based on Alpine linux?

like image 697
Marian Avatar asked Nov 18 '17 12:11

Marian


2 Answers

Here is a Dockerfile:

FROM alpine:3.6

RUN apk add --no-cache nginx-mod-http-lua

# Delete default config
RUN rm -r /etc/nginx/conf.d && rm /etc/nginx/nginx.conf

# Create folder for PID file
RUN mkdir -p /run/nginx

# Add our nginx conf
COPY ./nginx.conf /etc/nginx/nginx.conf

CMD ["nginx"]

Installing the nginx-mod-http-lua package will also install nginx and luajit, among others.

The nginx.conf should contain at least this:

load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;

pcre_jit on;

events {
  worker_connections 1024;
}

daemon off;
like image 55
Marian Avatar answered Oct 11 '22 02:10

Marian


Dockerfile:

FROM nginx:1.15-alpine
RUN  mkdir -p /run/nginx
RUN  apk add --no-cache nginx-mod-http-lua
COPY nginx_conf/ /etc/nginx/ # Your nginx conf
COPY lua/ /etc/lua/          # Your lua files 

First line of nginx conf:

load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
pcre_jit on;
like image 43
Piero Avatar answered Oct 11 '22 02:10

Piero