Detailed explanation of nginx-naxsi whitelist rules

Detailed explanation of nginx-naxsi whitelist rules

Whitelist rule syntax:

BasicRule wl:ID [negative] [mz:[$URL:target_url]|[match_zone]|[$ARGS_VAR:varname]|[$BODY_VARS:varname]|[$HEADERS_VAR:varname]|[NAME]]

wl:ID (White List ID) Which interception rules will be included in the whitelist
wl:0 Add all interception rules to the whitelist
wl:42 Add the interception rule with ID 42 to the whitelist
wl:42,41,43 Add interception rules with IDs 42, 41 and 43 to the whitelist
wl:-42 Add all interception rules to the whitelist, except for the interception rule with ID 42

mz:(Match Zones)

ARGS The entire GET parameter, such as: foo=bar&in=%20
$ARGS_VAR The parameter name of the GET parameter, such as foo and in in foo=bar&in=%20
$ARGS_VAR_X Parameter name of the GET parameter that matches the regular expression
HEADERS The entire HTTP protocol header
$HEADERS_VAR HTTP header name
$HEADERS_VAR_X The name of the HTTP protocol header that matches the regular expression
BODY The entire parameter content of POST
$BODY_VAR POST parameter name
$BODY_VAR_X Parameter name of the POST parameter that is matched by the regular expression
URL URL(before ?)
URL_X Regular matching URL (before?)
FILE_EXT File name (the file name uploaded when POST is used to upload a file)

Whitelist Configuration Example

Take rule #1000 as an example: Rule #1000 is a rule that filters SQL keywords such as select, update, delete, and insert.

rule illustrate
BasicRule wl:1000; Completely disable intercept rule #1000 in this subrule. Since no region is specified, all are added to the whitelist.
BasicRule wl:1000 "mz:$ARGS_VAR:foo";

Disable interception rule #1000 for all GET parameter values ​​named foo

Requests like http://mike.hi-linux.com/?foo=select * from demo will not be filtered.

BasicRule wl:1000 "mz:$URL:/bar|ARGS";

Disable interception rule #1000 for parameters in GET request with URL /bar

The following similar requests will not be filtered:

http://mike.hi-linux.com/bar?my=select * from demohttp://mike.hi-linux.com/bar?from=weibo

BasicRule wl:1000 "mz:ARGS|NAME";

Disable interception rule #1000 for all parameter names (just the name, not the parameter value) in all GET requests

The following requests are not filtered:

http://mike.hi-linux.com/bar?from=weibo

The following requests are filtered:

http://mike.hi-linux.com/bar?foo=select

Because select is a parameter value and is not within the whitelist.

BasicRule wl:0 "mz:$URL_X:^/upload/(.*).(.*)$|URL";

Disable all interception rules for URLs that match the ^/upload/(.*).(.*)$ regular rule in all requests

Requests like http://mike.hi-linux.com/upload/select.db will not be filtered (they would have triggered interception rule #1000).

Whitelist rules for actual combat# vi naxsi_BasicRule.conf
BasicRule wl:1010,1011 "mz:$ARGS_VAR:rd";
BasicRule wl:1015,1315 "mz:$HEADERS_VAR:cookie";

The above detailed explanation of the nginx-naxsi whitelist rules is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Example of setting up a whitelist in Nginx using the geo module
  • How to set directory whitelist and IP whitelist in nginx
  • How to dynamically add access whitelist to nginx
  • Configure a firewall with blacklist or whitelist function for the Nginx server

<<:  Bootstrap realizes the effect of carousel

>>:  MySQL 5.7.21 winx64 green version installation and configuration method graphic tutorial

Recommend

Analysis of the principle of using PDO to prevent SQL injection

Preface This article uses pdo's preprocessing...

Graphical introduction to the difference between := and = in MySQL

The difference between := and = = Only when setti...

Several principles for website product design reference

The following analysis is about product design pr...

Vue-cli framework implements timer application

Technical Background This application uses the vu...

js precise calculation

var numA = 0.1; var numB = 0.2; alert( numA + num...

How to deploy services in Windows Server 2016 (Graphic Tutorial)

introduction Sometimes, if there are a large numb...

Problems installing TensorRT in docker container

Uninstall the installed version on Ubuntu: sudo a...

Explore the truth behind the reload process in Nginx

Today's article mainly introduces the reload ...

MySQL database operations and data types

Table of contents 1. Database Operation 1.1 Displ...

Solution to the problem that order by is not effective in MySQL subquery

By chance, I discovered that a SQL statement prod...

Vue.js Textbox with Dropdown component

A Textbox with Dropdown allows users to select an...

Unity connects to MySQL and reads table data implementation code

The table is as follows: Code when Unity reads an...