Skip to content

Commit 9dc6c6f

Browse files
committed
Added GH workflow to build ModSecurity-nginx on Windows
1 parent 1c0324e commit 9dc6c6f

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

Diff for: .github/workflows/test.yml

+108
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,111 @@ jobs:
9191
echo "FAIL"
9292
exit 1
9393
fi
94+
95+
build-windows:
96+
runs-on: windows-2022
97+
defaults:
98+
run:
99+
shell: msys2 {0}
100+
steps:
101+
- name: Set up MSVC
102+
uses: ilammy/msvc-dev-cmd@v1
103+
- name: Set up msys
104+
uses: msys2/setup-msys2@v2
105+
with:
106+
msystem: UCRT64
107+
path-type: inherit
108+
- name: Get Nginx source
109+
uses: actions/checkout@v4
110+
with:
111+
repository: nginx/nginx
112+
path: nginx
113+
fetch-depth: 1
114+
- name: Get Nginx tests
115+
uses: actions/checkout@v4
116+
with:
117+
repository: nginx/nginx-tests
118+
path: nginx/test
119+
fetch-depth: 1
120+
- name: Set up third-party libraries
121+
working-directory: nginx
122+
run: |
123+
mkdir objs
124+
mkdir objs/lib
125+
cd objs/lib
126+
wget -q -O - https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.39/pcre2-10.39.tar.gz | tar -xzf -
127+
wget -q -O - https://www.zlib.net/fossils/zlib-1.3.tar.gz | tar -xzf -
128+
wget -q -O - https://www.openssl.org/source/openssl-3.0.13.tar.gz | tar -xzf -
129+
- name: Get libModSecurity source
130+
uses: actions/checkout@v4
131+
with:
132+
repository: owasp-modsecurity/ModSecurity
133+
submodules: true
134+
path: nginx/objs/lib/ModSecurity
135+
fetch-depth: 1
136+
- name: Setup Conan
137+
shell: cmd
138+
run: |
139+
pip3 install conan --upgrade
140+
conan profile detect
141+
- name: Build libModSecurity
142+
working-directory: nginx/objs/lib/ModSecurity
143+
shell: cmd
144+
run: |
145+
vcbuild.bat
146+
- name: Get ModSecurity-nginx source code
147+
uses: actions/checkout@v4
148+
with:
149+
path: nginx/objs/lib/ModSecurity-nginx
150+
- name: Copy ModSecurity-nginx tests to nginx/test
151+
working-directory: nginx/test
152+
run: |
153+
cp ../objs/lib/ModSecurity-nginx/tests/* .
154+
- name: Remove /usr/bin/link conflicting with MSVC link.exe
155+
run: |
156+
set -ex
157+
which link
158+
rm /usr/bin/link
159+
- name: Build nginx w/ModSecurity-nginx module
160+
working-directory: nginx
161+
run: |
162+
: # Windows native version of Perl is required by nginx build
163+
export PATH=/c/Strawberry/perl/bin:$PATH
164+
: # Set env variables to point to libModSecurity v3 include & lib directories
165+
export MODSECURITY_INC=objs/lib/ModSecurity/headers
166+
export MODSECURITY_LIB=objs/lib/ModSecurity/build/win32/build/Release
167+
: # Copy libModSecurity.dll to objs dir (to be able to run nginx later)
168+
cp $MODSECURITY_LIB/libModSecurity.dll objs
169+
: # Configure nginx build w/ModSecurity-nginx module
170+
auto/configure \
171+
--with-cc=cl \
172+
--with-debug \
173+
--prefix= \
174+
--conf-path=conf/nginx.conf \
175+
--pid-path=logs/nginx.pid \
176+
--http-log-path=logs/access.log \
177+
--error-log-path=logs/error.log \
178+
--sbin-path=nginx.exe \
179+
--http-client-body-temp-path=temp/client_body_temp \
180+
--http-proxy-temp-path=temp/proxy_temp \
181+
--http-fastcgi-temp-path=temp/fastcgi_temp \
182+
--http-scgi-temp-path=temp/scgi_temp \
183+
--http-uwsgi-temp-path=temp/uwsgi_temp \
184+
--with-cc-opt=-DFD_SETSIZE=1024 \
185+
--with-pcre=objs/lib/pcre2-10.39 \
186+
--with-zlib=objs/lib/zlib-1.3 \
187+
--with-openssl=objs/lib/openssl-3.0.13 \
188+
--with-openssl-opt=no-asm \
189+
--with-http_ssl_module \
190+
--with-http_v2_module \
191+
--with-http_auth_request_module \
192+
--add-module=objs/lib/ModSecurity-nginx
193+
nmake
194+
- name: Run ModSecurity-nginx tests
195+
working-directory: nginx/test
196+
shell: cmd # tests need to run on a "windows" shell
197+
run: |
198+
md temp
199+
set TEMP=temp
200+
set TEST_NGINX_BINARY=..\objs\nginx.exe
201+
prove modsecurity*.t

0 commit comments

Comments
 (0)