Bash scripts to automatically install and setup ModSecurity WAF to work with NGINX and add OWASP Core Rule Set (CRS).
Based on: ModSecurity v3 (libmodsecurity)
Tested against Ubuntu 16.04 & 18.04, but it should work with other Ubuntu distributions as well. Server: NGINX
Setup script will:
- Grab latest stable release of NGINX (PPA).
- Install prerequisites for ModSecurity.
- Setup ModSecurity-nginx connector based on current nginx version.
- Enable ModSecurity Module and add configuration files.
After running setup script, run this to automatically add OWASP Core Rule Set.
Reference: https://raw.githubusercontent.com/SpiderLabs/owasp-modsecurity-crs/v3.0/master/INSTALL
To do.
chmod +x setup.sh owasp.sh
sudo ./setup.sh
sudo ./owasp.sh
After installing these scripts:
nano /etc/nginx/<your_nginx_conf_file_location>
Turn on modsecurity
and modsecurity_rules_file
by adding this to your nginx conf file:
modsecurity on;
modsecurity_rules_file /etc/nginx/modsec/main.conf;
Example:
server {
# ...
modsecurity on;
modsecurity_rules_file /etc/nginx/modsec/main.conf;
}