Skip to content

Commit f1bc70f

Browse files
committed
更新 Nginx 版本至 1.16.1,ModSecurity 3.0.14
1 parent bd3a192 commit f1bc70f

File tree

4 files changed

+120
-10
lines changed

4 files changed

+120
-10
lines changed

Dockerfile.latest

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nginx:1.18.0-alpine AS builder
1+
FROM nginx:1.16.1-alpine AS builder
22

33
# 设置 ModSecurity 版本
44
ENV MODSECURITY_VERSION=v3.0.14
@@ -34,9 +34,9 @@ RUN apk add --no-cache --virtual .build-deps \
3434
WORKDIR /opt
3535

3636
# 下载 Nginx 源码
37-
RUN wget https://nginx.org/download/nginx-1.18.0.tar.gz \
38-
&& tar -xzf nginx-1.18.0.tar.gz \
39-
&& rm nginx-1.18.0.tar.gz
37+
RUN wget https://nginx.org/download/nginx-1.16.1.tar.gz \
38+
&& tar -xzf nginx-1.16.1.tar.gz \
39+
&& rm nginx-1.16.1.tar.gz
4040

4141
# 下载 ModSecurity
4242
RUN git clone --depth 1 -b ${MODSECURITY_VERSION} https://github.com/owasp-modsecurity/ModSecurity.git
@@ -55,15 +55,15 @@ RUN cd /opt/ModSecurity \
5555
&& make clean
5656

5757
# 编译 Nginx 与 ModSecurity 模块
58-
RUN cd /opt/nginx-1.18.0 \
58+
RUN cd /opt/nginx-1.16.1 \
5959
&& ./configure --with-compat --add-dynamic-module=/opt/ModSecurity-nginx \
6060
&& make modules \
6161
&& cp objs/ngx_http_modsecurity_module.so /etc/nginx/modules \
6262
&& mkdir -p /etc/nginx/modsec \
6363
&& cp /opt/ModSecurity/unicode.mapping /etc/nginx/modsec/
6464

6565
# 最终镜像
66-
FROM nginx:1.18.0-alpine AS final
66+
FROM nginx:1.16.1-alpine AS final
6767

6868
# 安装运行时依赖
6969
RUN apk add --no-cache --purge --virtual .runtime-deps \
@@ -84,7 +84,7 @@ COPY --from=builder /etc/nginx/modsec/unicode.mapping /etc/nginx/modsec/
8484

8585
# 添加构建信息标签
8686
LABEL maintainer="AptS-1547 <[email protected]>" \
87-
nginx_version="1.18.0" \
87+
nginx_version="1.16.1" \
8888
modsecurity_version="v3.0.14" \
8989
modsecurity_nginx_version="v1.0.3" \
90-
build_date="2025-05-21T08:08:48Z"
90+
build_date="2025-05-21T08:09:10Z"

nginx-1.16.1/mod-3.0.14/Dockerfile

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
FROM nginx:1.16.1-alpine AS builder
2+
3+
# 设置 ModSecurity 版本
4+
ENV MODSECURITY_VERSION=v3.0.14
5+
ENV MODSECURITY_NGINX_VERSION=v1.0.3
6+
7+
# 安装构建依赖
8+
RUN apk add --no-cache --virtual .build-deps \
9+
alpine-sdk \
10+
autoconf \
11+
automake \
12+
bison \
13+
curl \
14+
doxygen \
15+
flex \
16+
g++ \
17+
gcc \
18+
git \
19+
libtool \
20+
lmdb-dev \
21+
lua5.4-dev \
22+
make \
23+
curl-dev \
24+
pcre2-dev \
25+
yajl-dev \
26+
zlib-dev \
27+
libxml2-dev \
28+
geoip-dev \
29+
pcre-dev \
30+
linux-headers \
31+
wget
32+
33+
# 创建工作目录
34+
WORKDIR /opt
35+
36+
# 下载 Nginx 源码
37+
RUN wget https://nginx.org/download/nginx-1.16.1.tar.gz \
38+
&& tar -xzf nginx-1.16.1.tar.gz \
39+
&& rm nginx-1.16.1.tar.gz
40+
41+
# 下载 ModSecurity
42+
RUN git clone --depth 1 -b ${MODSECURITY_VERSION} https://github.com/owasp-modsecurity/ModSecurity.git
43+
44+
# 下载 ModSecurity-nginx 连接器
45+
RUN git clone --depth 1 -b ${MODSECURITY_NGINX_VERSION} https://github.com/owasp-modsecurity/ModSecurity-nginx.git
46+
47+
# 编译 ModSecurity
48+
RUN cd /opt/ModSecurity \
49+
&& git submodule init \
50+
&& git submodule update \
51+
&& ./build.sh \
52+
&& ./configure --prefix=/usr/local/modsecurity --with-lmdb --with-pcre2 \
53+
&& make \
54+
&& make install \
55+
&& make clean
56+
57+
# 编译 Nginx 与 ModSecurity 模块
58+
RUN cd /opt/nginx-1.16.1 \
59+
&& ./configure --with-compat --add-dynamic-module=/opt/ModSecurity-nginx \
60+
&& make modules \
61+
&& cp objs/ngx_http_modsecurity_module.so /etc/nginx/modules \
62+
&& mkdir -p /etc/nginx/modsec \
63+
&& cp /opt/ModSecurity/unicode.mapping /etc/nginx/modsec/
64+
65+
# 最终镜像
66+
FROM nginx:1.16.1-alpine AS final
67+
68+
# 安装运行时依赖
69+
RUN apk add --no-cache --purge --virtual .runtime-deps \
70+
lua5.4 \
71+
yajl \
72+
libstdc++ \
73+
pcre2 \
74+
lmdb \
75+
geoip \
76+
libxml2 \
77+
curl
78+
79+
# 复制配置文件和模块
80+
RUN sed -i '1i load_module modules/ngx_http_modsecurity_module.so;\n' /etc/nginx/nginx.conf
81+
COPY --from=builder /usr/local/modsecurity/ /usr/local/modsecurity/
82+
COPY --from=builder /etc/nginx/modules/ngx_http_modsecurity_module.so /etc/nginx/modules/
83+
COPY --from=builder /etc/nginx/modsec/unicode.mapping /etc/nginx/modsec/
84+
85+
# 添加构建信息标签
86+
LABEL maintainer="AptS-1547 <[email protected]>" \
87+
nginx_version="1.16.1" \
88+
modsecurity_version="v3.0.14" \
89+
modsecurity_nginx_version="v1.0.3" \
90+
build_date="2025-05-21T08:09:10Z"

nginx-1.16.1/mod-3.0.14/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ModSecurity with Nginx
2+
3+
版本信息:
4+
- Nginx: 1.16.1
5+
- ModSecurity: v3.0.14
6+
- ModSecurity-nginx: v1.0.3
7+
8+
创建日期: 2025-05-21T08:09:10Z
9+
10+
## 构建镜像
11+
12+
```bash
13+
docker build -t modsecurity:1.16.1-3.0.14 .
14+
```
15+
16+
## 运行容器
17+
18+
```bash
19+
docker run -d -p 80:80 modsecurity:1.16.1-3.0.14
20+
```

versions.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NGINX_VERSION=1.18.0
1+
NGINX_VERSION=1.16.1
22
MODSECURITY_VERSION=v3.0.14
33
MODSECURITY_NGINX_VERSION=v1.0.3
4-
BUILD_DATE=2025-05-21T08:08:48Z
4+
BUILD_DATE=2025-05-21T08:09:10Z

0 commit comments

Comments
 (0)