Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use stable version of modsecurity nginx connector #328

Merged
merged 3 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ variable "httpd-version" {
default = "2.4.63"
}

variable "modsecurity-nginx-version" {
default = "1.0.3"
}

variable "lua-version" {
default = "5.3"
}
Expand Down Expand Up @@ -105,7 +109,7 @@ target "docker-metadata-action" {}

target "platforms-base" {
inherits = ["docker-metadata-action"]
context="."
context="."
platforms = ["linux/amd64", "linux/arm64/v8", "linux/arm/v7", "linux/i386"]
labels = {
"org.opencontainers.image.source" = "https://github.com/coreruleset/modsecurity-crs-docker"
Expand Down Expand Up @@ -150,6 +154,7 @@ target "nginx" {
LUA_MODULES = join(" ", lua-modules-debian)
NGINX_VERSION = "${nginx-version}"
NGINX_DYNAMIC_MODULES = join(" ", nginx-dynamic-modules)
MODSECURITY_NGINX_VERSION = "${modsecurity-nginx-version}"
}
tags = concat(tag("nginx"),
vtag("${crs-version}", "nginx")
Expand All @@ -163,9 +168,9 @@ target "nginx-alpine" {
LUA_MODULES = join(" ", lua-modules-alpine)
NGINX_DYNAMIC_MODULES = join(" ", nginx-dynamic-modules)
NGINX_VERSION = "${nginx-version}"
MODSECURITY_NGINX_VERSION = "${modsecurity-nginx-version}"
}
tags = concat(tag("nginx-alpine"),
vtag("${crs-version}", "nginx-alpine")
)
}

11 changes: 8 additions & 3 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ARG MODSEC3_VERSION="n/a"
ARG LMDB_VERSION="n/a"
ARG LUA_VERSION="n/a"
ARG NGINX_DYNAMIC_MODULES="n/a"
ARG MODSECURITY_NGINX_VERSION="n/a"

USER root

Expand Down Expand Up @@ -53,7 +54,7 @@ RUN set -eux; \
sed -ie "s/i386-linux-gnu/${ARCH}/g" build/pcre2.m4; \
./build.sh; \
./configure --with-yajl --with-ssdeep --with-pcre2 --with-maxmind --enable-silent-rules; \
make install; \
make -j$(nproc) install; \
strip /usr/local/modsecurity/lib/lib*.so*

# Build modules
Expand All @@ -62,14 +63,18 @@ RUN set -eux; \
for module in ${NGINX_DYNAMIC_MODULES}; \
do \
repo=$(echo "${module}" | awk -F'/' '{print $2}'); \
git clone -b master --depth 1 "https://github.com/${module}.git" ; \
if [ "${module}" == "owasp-modsecurity/ModSecurity-nginx" ]; then \
git clone -b v${MODSECURITY_NGINX_VERSION} --depth 1 "https://github.com/${module}.git"; \
else \
git clone -b master --depth 1 "https://github.com/${module}.git"; \
fi; \
modules="${modules} --add-dynamic-module=../${repo}"; \
done; \
curl -sSL "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -o nginx-${NGINX_VERSION}.tar.gz; \
tar -xzf nginx-${NGINX_VERSION}.tar.gz; \
cd ./nginx-${NGINX_VERSION}; \
./configure --with-compat ${modules}; \
make modules; \
make -j$(nproc) modules; \
strip objs/*.so; \
cp objs/*.so /etc/nginx/modules/; \
mkdir /etc/modsecurity.d; \
Expand Down
11 changes: 8 additions & 3 deletions nginx/Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM nginxinc/nginx-unprivileged:${NGINX_VERSION}-alpine AS build
ARG MODSEC3_VERSION="n/a"
ARG LUA_VERSION="n/a"
ARG NGINX_DYNAMIC_MODULES="n/a"
ARG MODSECURITY_NGINX_VERSION="n/a"

USER root

Expand Down Expand Up @@ -49,7 +50,7 @@ RUN set -eux; \
sed -ie "s/i386-linux-gnu/${ARCH}/g" build/pcre2.m4; \
./build.sh; \
./configure --with-yajl --with-ssdeep --with-lmdb --with-pcre2 --with-maxmind --enable-silent-rules; \
make install; \
make -j$(nproc) install; \
strip /usr/local/modsecurity/lib/lib*.so*

# Build modules
Expand All @@ -58,14 +59,18 @@ RUN set -eux; \
for module in ${NGINX_DYNAMIC_MODULES}; \
do \
repo=$(echo "${module}" | awk -F'/' '{print $2}'); \
git clone -b master --depth 1 "https://github.com/${module}.git" ; \
if [ "${module}" == "owasp-modsecurity/ModSecurity-nginx" ]; then \
git clone -b v${MODSECURITY_NGINX_VERSION} --depth 1 "https://github.com/${module}.git"; \
else \
git clone -b master --depth 1 "https://github.com/${module}.git"; \
fi; \
modules="${modules} --add-dynamic-module=../${repo}"; \
done; \
curl -sSL https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -o nginx-${NGINX_VERSION}.tar.gz; \
tar -xzf nginx-${NGINX_VERSION}.tar.gz; \
cd ./nginx-${NGINX_VERSION}; \
./configure --with-compat ${modules}; \
make modules; \
make -j$(nproc) modules; \
strip objs/*.so; \
cp objs/*.so /etc/nginx/modules/; \
mkdir /etc/modsecurity.d; \
Expand Down