Setting up ModSecurity WAF for Nginx Webserver
1 minute read •
Note we need to perform all of these on the “server” that we’re installing ModSecurity for.
Install and check the nginx version
# Check the version
It should give similar results like the following:
)
We can see it’s version is 1.24.0. We need to keep this in mind because we’re going to build ModSecurity for this version of nginx.
Install build tools
We need to install some build tools to build ModSecurity from source.
Build ModSecurity
- Clone the ModSecurity Github repository in
/optdirectory
cdintoModSecurity
- Run the
./buildscript
- Run the
./configurefile, which is responsible for getting all the dependencies for the build process:
- Run the
makecommand to build ModSecurity:
- After the build process is complete, install ModSecurity by running the following command:
Downloading ModSecurity-Nginx Connector
Before compiling the ModSecurity module, clone the Nginx-connector from the /optdirectory:
Building the ModSecurity Module For Nginx
You can now build the ModSecurity module from a downloaded copy of your Nginx version by following the steps outlined below: