Skip to content

Commit d99eee3

Browse files
committed
更新 Nginx 至 1.24.0, ModSecurity 至 v3.0.14
1 parent 8d1b013 commit d99eee3

File tree

8 files changed

+249
-12
lines changed

8 files changed

+249
-12
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.26.3-alpine AS builder
1+
FROM nginx:1.24.0-alpine AS builder
22

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

3535
# 下载 Nginx 源码
36-
RUN wget https://nginx.org/download/nginx-1.26.3.tar.gz \
37-
&& tar -xzf nginx-1.26.3.tar.gz \
38-
&& rm nginx-1.26.3.tar.gz
36+
RUN wget https://nginx.org/download/nginx-1.24.0.tar.gz \
37+
&& tar -xzf nginx-1.24.0.tar.gz \
38+
&& rm nginx-1.24.0.tar.gz
3939

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

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

6464
# 最终镜像
65-
FROM nginx:1.26.3-alpine AS final
65+
FROM nginx:1.24.0-alpine AS final
6666

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

8383
# 添加构建信息标签
8484
LABEL maintainer="AptS-1547 <[email protected]>" \
85-
nginx_version="1.26.3" \
85+
nginx_version="1.24.0" \
8686
modsecurity_version="v3.0.14" \
8787
modsecurity_nginx_version="v1.0.3" \
88-
build_date="2025-05-21T04:47:38Z"
88+
build_date="2025-05-21T05:00:13Z"

latest_version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.26.3
1+
1.26.3

nginx-1.22.1/mod-3.0.14/Dockerfile

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

nginx-1.22.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.22.1
5+
- ModSecurity: v3.0.14
6+
- ModSecurity-nginx: v1.0.3
7+
8+
创建日期: 2025-05-21T04:48:17Z
9+
10+
## 构建镜像
11+
12+
```bash
13+
docker build -t modsecurity:1.22.1-3.0.14 .
14+
```
15+
16+
## 运行容器
17+
18+
```bash
19+
docker run -d -p 80:80 modsecurity:1.22.1-3.0.14
20+
```

nginx-1.24.0/mod-3.0.14/Dockerfile

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

nginx-1.24.0/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.24.0
5+
- ModSecurity: v3.0.14
6+
- ModSecurity-nginx: v1.0.3
7+
8+
创建日期: 2025-05-21T05:00:13Z
9+
10+
## 构建镜像
11+
12+
```bash
13+
docker build -t modsecurity:1.24.0-3.0.14 .
14+
```
15+
16+
## 运行容器
17+
18+
```bash
19+
docker run -d -p 80:80 modsecurity:1.24.0-3.0.14
20+
```

update.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
NGINX_VERSION=${1:-"1.26.3"}
55
MODSECURITY_VERSION=${2:-"v3.0.14"}
66
MODSECURITY_NGINX_VERSION=${3:-"v1.0.3"}
7+
AUTO_PUSH=${4:-"false"} # 新增参数,控制是否自动提交和推送
78

89
# 移除版本号中的 'v' 前缀,便于文件夹命名
910
MOD_VERSION=${MODSECURITY_VERSION#v}
@@ -21,6 +22,7 @@ echo "Nginx: $NGINX_VERSION"
2122
echo "ModSecurity: $MODSECURITY_VERSION"
2223
echo "ModSecurity-nginx: $MODSECURITY_NGINX_VERSION"
2324
echo "导出目录: $VERSION_DIR"
25+
echo "自动提交并推送: $AUTO_PUSH"
2426
echo
2527

2628
# 生成版本化目录的 Dockerfile
@@ -45,6 +47,9 @@ MODSECURITY_NGINX_VERSION=$MODSECURITY_NGINX_VERSION
4547
BUILD_DATE=$BUILD_DATE
4648
EOF
4749

50+
# 更新最新版本文件
51+
echo "$NGINX_VERSION" > "latest_version"
52+
4853
# 创建一个README文件,记录版本信息
4954
cat > "$VERSION_DIR/README.md" << EOF
5055
# ModSecurity with Nginx
@@ -72,4 +77,20 @@ EOF
7277
echo "更新完成!文件已导出到 $VERSION_DIR 目录"
7378
echo "同时已生成 Dockerfile.latest 和 versions.env 文件在根目录"
7479
echo "您可以运行以下命令构建镜像:"
75-
echo "cd $VERSION_DIR && docker build -t modsecurity:$NGINX_VERSION-$MOD_VERSION ."
80+
echo "cd $VERSION_DIR && docker build -t modsecurity:$NGINX_VERSION-$MOD_VERSION ."
81+
82+
# 如果设置了自动提交和推送
83+
if [ "$AUTO_PUSH" = "true" ]; then
84+
echo "正在提交更改..."
85+
git add "$VERSION_DIR" Dockerfile.latest versions.env latest_version
86+
git commit -m "更新 Nginx 至 $NGINX_VERSION, ModSecurity 至 $MODSECURITY_VERSION"
87+
88+
echo "正在推送到远程仓库..."
89+
git push
90+
91+
if [ $? -eq 0 ]; then
92+
echo "提交和推送成功完成!"
93+
else
94+
echo "推送失败,请手动检查并推送。"
95+
fi
96+
fi

versions.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NGINX_VERSION=1.26.3
1+
NGINX_VERSION=1.24.0
22
MODSECURITY_VERSION=v3.0.14
33
MODSECURITY_NGINX_VERSION=v1.0.3
4-
BUILD_DATE=2025-05-21T04:47:38Z
4+
BUILD_DATE=2025-05-21T05:00:13Z

0 commit comments

Comments
 (0)