Enable SecRuleEngine, edit /etc/nginx/modsecurity.conf and change
SecRuleEngine DetectionOnly
to
SecRuleEngine On
Check nginx version should be like this
# nginx -V
nginx version: nginx/1.16.1
built by gcc 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC)
built with OpenSSL 1.1.1 FIPS 11 Sep 2018
TLS SNI support enabled
configure arguments: .........
Disable Nginx update by edit /etc/dnf/dnf.conf by adding this code
exclude=nginx*
Configure Nginx to use ModSecurity module
To load ModSecurity on Nginx, edit /etc/nginx/nginx.conf and add this code in top of configuration.
# cd /etc/nginx
# wget https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.2.0.zip
# unzip v3.2.0.zip
# mv owasp-modsecurity-crs-3.2.0 owasp-modsecurity-crs
#### OR BY CLONE
# git clone https://github.com/SpiderLabs/owasp-modsecurity-crs.git
# cp owasp-modsecurity-crs/crs-setup.conf.example owasp-modsecurity-crs/crs-setup.conf
Create /etc/nginx/modsec_includes.conf and add code below
include modsecurity.conf
include /etc/nginx/owasp-modsecurity-crs/crs-setup.conf
include /etc/nginx/owasp-modsecurity-crs/rules/*.conf
# Additional custom rules here
SecRule REQUEST_URI "@beginsWith /rss/" "phase:1,t:none,pass,id:'26091902',nolog,ctl:ruleRemoveById=200002"
Check your Nginx configuration with
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
If no problem, start Nginx
# systemctl restart nginx
Testing Nginx ModSecurity
Check on your rules for blacklist user agent, for Comodo rules is bl_agents
I do consider all the concepts you’ve offered in your post. They’re really convincing and can definitely work. Nonetheless, the posts are very short for novices. May you please extend them a bit from next time? Thank you for the post.
There are some lines missing, i.e. inside which directory you are running ./configure… command?
I do consider all the concepts you’ve offered in your post. They’re really convincing and can definitely work. Nonetheless, the posts are very short for novices. May you please extend them a bit from next time? Thank you for the post.