ModSecurity#
The module adds a web application firewall (WAF) to Angie, based on
ModSecurity; upstream, it is called the
ModSecurity-nginx connector. Angie passes requests and responses to the
ModSecurity library, which checks them against rules such as the OWASP Core Rule
Set. Whether traffic that matches a rule is blocked or only logged depends on
the rule and on the To install the module, use one of the following packages: Angie: Angie PRO: To work with the module, you need to load it in the Specify the Copy the OWASP Core Rule Set for ModSecurity (CRS)
to the Tip This is the CRS version that the package suggests in
In the directory with the core rules,
copy the minimally required ModSecurity configuration examples: Uncomment the Version: v1.0.4 The version above is that of the connector module; the packages are built against
version 3.0.17 of the ModSecurity library. Detailed documentation and source code are available at:
owasp-modsecurity/ModSecurity-nginx.SecRuleEngine mode in the ModSecurity configuration.
The packaged /etc/angie/modsecurity/modsecurity.conf sets
DetectionOnly, which only logs matches; to block matching traffic, set
SecRuleEngine On in that file.Installation#
angie-module-modsecurityangie-pro-module-modsecurityLoading the Module#
main{} context:load_module modules/ngx_http_modsecurity_module.so;
Configuration Example#
modsecurity and modsecurity_rules_file directives
in the appropriate context, for example server:server {
modsecurity on;
modsecurity_rules_file /etc/angie/modsecurity/rules.conf;
# ...
}
/var/lib/angie/modsecurity/ directory:$ cd /var/lib/angie/modsecurity/
$ sudo git clone -b v3.3.5 https://github.com/coreruleset/coreruleset
/etc/angie/modsecurity/rules.conf.
Other CRS releases are listed here:
coreruleset/coreruleset$ sudo cp coreruleset/crs-setup.conf.example coreruleset/crs-setup.conf
$ sudo cp coreruleset/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf.example \
coreruleset/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
$ sudo cp coreruleset/rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example \
coreruleset/rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf
Include directives below
in the /etc/angie/modsecurity/rules.conf file:Include /var/lib/angie/modsecurity/coreruleset/crs-setup.conf
Include /var/lib/angie/modsecurity/coreruleset/rules/*.conf
Additional Information#