http-naxsi #
NAXSI is a web application firewall for nginx that blocks requests which look like SQL injection or cross-site scripting. Use it with its small core rule set plus allow rules for your application. Learning mode helps you write those rules.
Source: upstream source
Directives
BasicRule #
syntax: BasicRule 1+ args; · context: http, server, location, limit_except
BasicRule (in loc)
IgnoreCIDR #
syntax: IgnoreCIDR 1+ args; · context: http, server, location, limit_except
WhitelistCIDR
LearningMode #
syntax: LearningMode no args; · context: http, server, location, limit_except
* flag rules / /* Learning Flag
LibInjectionSql #
syntax: LibInjectionSql no args; · context: http, server, location, limit_except
LibInjectionSql
LibInjectionXss #
syntax: LibInjectionXss no args; · context: http, server, location, limit_except
LibInjectionXss
NaxsiLogFile #
syntax: NaxsiLogFile 1+ args; · context: http, server, location, limit_except
NaxsiLogfile
SecRulesDisabled #
syntax: SecRulesDisabled no args; · context: http, server, location, limit_except
DisableFlag
SecRulesEnabled #
syntax: SecRulesEnabled no args; · context: http, server, location, limit_except
EnableFlag
basic_rule #
syntax: basic_rule 1+ args; · context: http, server, location, limit_except
BasicRule (in loc) - nginx style
check_rule #
syntax: check_rule 1+ args; · context: http, server, location, limit_except
CheckRule - nginx style
denied_url #
syntax: denied_url 1+ args; · context: http, server, location, limit_except
DeniedUrl - nginx style
ignore_cidr #
syntax: ignore_cidr 1+ args; · context: http, server, location, limit_except
WhitelistCIDR - nginx style
ignore_ip #
syntax: ignore_ip 1+ args; · context: http, server, location, limit_except
WhitelistIP - nginx style
learning_mode #
syntax: learning_mode no args; · context: http, server, location, limit_except
Learning Flag (nginx style)
libinjection_sql #
syntax: libinjection_sql no args; · context: http, server, location, limit_except
LibInjectionSql (nginx style)
libinjection_xss #
syntax: libinjection_xss no args; · context: http, server, location, limit_except
LibInjectionXss (nginx style)
naxsi_log #
syntax: naxsi_log 1+ args; · context: http, server, location, limit_except
NaxsiLogfile - nginx style
rules_disabled #
syntax: rules_disabled no args; · context: http, server, location, limit_except
DisableFlag (nginx style)
rules_enabled #
syntax: rules_enabled no args; · context: http, server, location, limit_except
EnableFlag (nginx style)
Example
set $naxsi_json_log 1;
location / {
BasicRule wl:1000,1001,1002,1005,1007,1010,1011,1015,1016,1100,1101,1200,1315 "mz:$HEADERS_VAR:cookie";
BasicRule wl:1310,1311 "mz:$URL_X:^/my-account/profile|BODY|NAME";
BasicRule wl:17,1010,1011,1015,1200 "mz:$URL_X:^/my-account/profile|$BODY_VAR_X:^sportactivities\[[0-9]\]\.";
BasicRule wl:17,1010,1011,1015,1200 "mz:$URL_X:^/my-account/profile|$BODY_VAR_X:^addresses\[[0-9]\]\.";
BasicRule wl:1009,1101 "mz:$URL_X:^/my-account/profile|$BODY_VAR_X:^return";
SecRulesEnabled;
LearningMode;
LibInjectionSql;
LibInjectionXss;
DeniedUrl "/RequestDenied";
CheckRule "$SQL >= 8" BLOCK;
CheckRule "$RFI >= 8" BLOCK;
CheckRule "$TRAVERSAL >= 5" BLOCK;
CheckRule "$UPLOAD >= 5" BLOCK;
CheckRule "$XSS >= 8" BLOCK;
CheckRule "$UWA >= 8" DROP;
CheckRule "$EVADE >= 8" BLOCK;
CheckRule "$LOG >= 1" LOG;
root $TEST_NGINX_SERVROOT/html/;
index index.html index.htm;
error_page 405 = $uri;
}
location /RequestDenied {
return 412;
}