Skip to content

Commit fa67d72

Browse files
authored
Merge branch 'master' into ssl-dhparam-fix
2 parents 383eb37 + 9da3f7a commit fa67d72

File tree

6 files changed

+62
-15
lines changed

6 files changed

+62
-15
lines changed

.github/workflows/dockerimage.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ jobs:
2525

2626
- name: Serve a static asset
2727
run: |
28-
docker run --detach --rm -p 0.0.0.0:8888:80 -v "$PWD/tests":/static:ro -v "$PWD/tests/static.conf":/etc/nginx/conf.d/static.conf:ro --name test_nginx -t ${{ github.repository }}
28+
docker run --detach --rm -p 0.0.0.0:8888:80 -v "$PWD/tests":/static:ro -v "$PWD/tests/static.conf":/etc/nginx/conf.d/static.conf:ro -v "$PWD/tests/env.conf":/etc/nginx/main.d/env.conf:ro --env FOO=foo-test-value --name test_nginx -t ${{ github.repository }}
2929
sleep 2; docker ps
30-
curl -v --compressed 0.0.0.0:8888
30+
curl -v --compressed 0.0.0.0:8888 2>&1 | tee /tmp/out
31+
32+
# assert response headers presense
33+
grep 'X-Foo: foo-test-value' /tmp/out
34+
3135
docker logs test_nginx

Dockerfile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
FROM alpine:3.12
2-
3-
ARG NGINX_VERSION=1.19.2
1+
ARG NGINX_VERSION=1.19.3
42

53
# https://github.com/google/ngx_brotli
64
ARG NGX_BROTLI_COMMIT=25f86f0bac1101b6512135eac5f93c49c63609e3
5+
6+
# https://github.com/vision5/ngx_devel_kit/releases
7+
# https://hub.docker.com/r/firesh/nginx-lua/dockerfile
8+
ARG NGX_DEVEL_KIT_VERSION=0.3.1
9+
10+
# https://github.com/openresty/luajit2/releases
11+
ARG LUA_NGINX_MODULE_VERSION=0.10.14
12+
713
ARG CONFIG="\
814
--prefix=/etc/nginx \
915
--sbin-path=/usr/sbin/nginx \
@@ -49,6 +55,9 @@ ARG CONFIG="\
4955
--with-file-aio \
5056
--with-http_v2_module \
5157
--add-module=/usr/src/ngx_brotli \
58+
--with-ld-opt="-Wl,-rpath,/usr/lib" \
59+
--add-module=/tmp/ngx_devel_kit-${NGX_DEVEL_KIT_VERSION} \
60+
--add-module=/tmp/lua-nginx-module-${LUA_NGINX_MODULE_VERSION} \
5261
"
5362

5463
FROM alpine:3.12
@@ -57,6 +66,8 @@ LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
5766
ARG NGINX_VERSION
5867
ARG NGX_BROTLI_COMMIT
5968
ARG CONFIG
69+
ARG NGX_DEVEL_KIT_VERSION
70+
ARG LUA_NGINX_MODULE_VERSION
6071

6172
RUN \
6273
apk add --no-cache --virtual .build-deps \
@@ -72,6 +83,8 @@ RUN \
7283
libxslt-dev \
7384
gd-dev \
7485
geoip-dev \
86+
luajit \
87+
luajit-dev \
7588
&& apk add --no-cache --virtual .brotli-build-deps \
7689
autoconf \
7790
libtool \
@@ -83,8 +96,14 @@ RUN \
8396
COPY nginx.pub /tmp/nginx.pub
8497

8598
RUN \
86-
echo "Compiling nginx $NGINX_VERSION with brotli $NGX_BROTLI_COMMIT" \
87-
&& mkdir -p /usr/src/ngx_brotli \
99+
echo "Fetcing lua-nginx-module $LUA_NGINX_MODULE_VERSION and nginx devel kit $NGX_DEVEL_KIT_VERSION ..." \
100+
&& curl -fSL https://github.com/simpl/ngx_devel_kit/archive/v${NGX_DEVEL_KIT_VERSION}.tar.gz -o /tmp/ndk.tar.gz \
101+
&& tar -xvf /tmp/ndk.tar.gz -C /tmp \
102+
&& curl -fSL https://github.com/openresty/lua-nginx-module/archive/v${LUA_NGINX_MODULE_VERSION}.tar.gz -o /tmp/lua-nginx.tar.gz \
103+
&& tar -xvf /tmp/lua-nginx.tar.gz -C /tmp
104+
105+
RUN \
106+
mkdir -p /usr/src/ngx_brotli \
88107
&& cd /usr/src/ngx_brotli \
89108
&& git init \
90109
&& git remote add origin https://github.com/google/ngx_brotli.git \
@@ -102,7 +121,10 @@ RUN \
102121
&& tar -zxC /usr/src -f nginx.tar.gz
103122

104123
RUN \
105-
cd /usr/src/nginx-$NGINX_VERSION \
124+
export LUAJIT_LIB=/usr/lib \
125+
&& export LUAJIT_INC=/usr/include/luajit-2.1 \
126+
&& echo "Compiling nginx $NGINX_VERSION with brotli $NGX_BROTLI_COMMIT and lua nginx module v$LUA_NGINX_MODULE_VERSION ..." \
127+
&& cd /usr/src/nginx-$NGINX_VERSION \
106128
&& ./configure $CONFIG --with-debug \
107129
&& make -j$(getconf _NPROCESSORS_ONLN) \
108130
&& mv objs/nginx objs/nginx-debug \
@@ -147,6 +169,8 @@ RUN \
147169

148170
FROM alpine:3.12
149171
ARG NGINX_VERSION
172+
ARG NGX_BROTLI_COMMIT
173+
ARG LUA_NGINX_MODULE_VERSION
150174

151175
COPY --from=0 /tmp/runDeps.txt /tmp/runDeps.txt
152176
COPY --from=0 /etc/nginx /etc/nginx
@@ -171,6 +195,10 @@ RUN \
171195
COPY nginx.conf /etc/nginx/nginx.conf
172196
COPY ssl_common.conf /etc/nginx/conf.d/ssl_common.conf
173197

198+
ENV NGINX_VERSION $NGINX_VERSION
199+
ENV NGX_BROTLI_COMMIT $NGX_BROTLI_COMMIT
200+
ENV LUA_NGINX_MODULE_VERSION $LUA_NGINX_MODULE_VERSION
201+
174202
EXPOSE 80 443
175203

176204
STOPSIGNAL SIGTERM

nginx.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ http {
3232

3333
include /etc/nginx/conf.d/*.conf;
3434
}
35+
36+
# this allows you to call directives such as "env" in your own conf files
37+
# http://nginx.org/en/docs/ngx_core_module.html#env
38+
include /etc/nginx/main.d/*.conf;

readme.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
# What is this?
1+
## What is this?
22
This project is based on Alpine Linux, the official nginx image and an nginx module that provides static and dynamic brotli compression. [Brotli](https://github.com/google/brotli) and the [nginx brotli module ](https://github.com/google/ngx_brotli) are built by Google.
33

4-
# How to use this image
4+
## How to use this image
55
As this project is based on the official [nginx image](https://hub.docker.com/_/nginx/) look for instructions there. In addition to the standard configuration directives, you'll be able to use the brotli module specific ones, see [here for official documentation](https://github.com/google/ngx_brotli#configuration-directives)
66

77
```
8-
docker pull macbre/nginx-brotli:1.19.2
8+
docker pull macbre/nginx-brotli:1.19.3
99
```
1010

11-
# What's inside
11+
## What's inside
1212

1313
```
1414
$ docker run -it macbre/nginx-brotli nginx -V
15-
nginx version: nginx/1.19.2
15+
nginx version: nginx/1.19.3
1616
built by gcc 9.3.0 (Alpine 9.3.0)
1717
built with OpenSSL 1.1.1g 21 Apr 2020
1818
TLS SNI support enabled
19-
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-compat --with-file-aio --with-http_v2_module --add-module=/usr/src/ngx_brotli
19+
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-compat --with-file-aio --with-http_v2_module --add-module=/usr/src/ngx_brotli --with-ld-opt=-Wl,-rpath,/usr/lib --add-module=/tmp/ngx_devel_kit-0.3.1 --add-module=/tmp/lua-nginx-module-0.10.14
2020
```
2121

2222
> [nginx release notes](https://nginx.org/en/CHANGES)
2323
24-
# SSL Grade A+ handling
24+
## SSL Grade A+ handling
2525

2626
Please refer to [Mozilla's SSL Configuration Generator](https://ssl-config.mozilla.org/). This image has `https://ssl-config.mozilla.org/ffdhe2048.txt` DH parameters for DHE ciphers fetched and stored in `/etc/ssl/dhparam.pem`:
2727

2828
```
2929
ssl_dhparam /etc/ssl/dhparam.pem;
3030
```
31+
32+
## nginx config files includes
33+
34+
* `.conf` files mounted in `/etc/nginx/main.d` will be included in the `main` nginx context (e.g. you can call [`env` directive](http://nginx.org/en/docs/ngx_core_module.html#env) there)
35+
* `.conf` files mounted in `/etc/nginx/conf.d` will be included in the `http` nginx context

tests/env.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
env FOO;

tests/static.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ server {
99
brotli_static on;
1010

1111
expires 1d;
12+
13+
# test lua module, see env.conf too
14+
set_by_lua $foo_from_env 'return os.getenv("FOO")';
15+
16+
add_header X-Foo $foo_from_env;
1217
}
1318
}

0 commit comments

Comments
 (0)