ModSecurity Nginx & OWASP
Step 1:
Name
modsec_nginx
Details
modsecuriry_nginx
Parameter
--add-module=/opt/ModSecurity-nginx
Prefix script
apt install gcc make build-essential autoconf automake libtool libcurl4-openssl-dev liblua5.3-dev libfuzzy-dev ssdeep gettext pkg-config libgeoip-dev libyajl-dev doxygen libpcre++-dev libpcre2-16-0 libpcre2-dev libpcre2-posix3 zlib1g zlib1g-dev -y
cd /opt && sudo git clone https://github.com/owasp-modsecurity/ModSecurity.git
cd ModSecurity
git submodule init
git submodule update
./build.sh
./configure
make
make install
git clone https://github.com/owasp-modsecurity/ModSecurity-nginx.git /opt/ModSecurity-nginx
Step 2:
Open terminal
cp /opt/ModSecurity/modsecurity.conf-recommended /www/server/nginx/modsecurity.conf
cp /opt/ModSecurity/unicode.mapping /www/server/nginx/unicode.mapping
git clone https://github.com/coreruleset/coreruleset.git /www/server/nginx/owasp-crs
cp /www/server/nginx/owasp-crs/crs-setup.conf{.example,}
Step 3:
Change SecRuleEngine to On /www/server/nginx/modsecurity.conf
SecRuleEngine On
Also update insert this configuration on bottom line to load owasp crs
Include owasp-crs/crs-setup.conf
Include owasp-crs/rules/*.conf
Step 4:
Add this to your web config Go to Website >> Select Domain >> Config
modsecurity on;
modsecurity_rules_file /www/server/nginx/modsecurity.conf;