check_rule

The `check_rule` directive in the NGINX Anti XSS & SQL Injection module is used to apply security rules to HTTP requests based on specified conditions.

Syntaxcheck_rule rule_pattern1 [rule_pattern2 ...];
Defaultnone
Contexthttp, server, location, limit_except
Arguments1+

Description

The check_rule directive allows administrators to specify one or more rules that NGINX should evaluate for incoming requests. These rules typically relate to patterns that are characteristic of XSS (Cross-site Scripting) or SQL Injection attacks. The directive can be applied in various contexts such as http, server, location, and limit_except, allowing fine-grained control over where and how they are implemented. By default, the module utilizes a pre-defined set of common patterns that identify potential vulnerabilities, but administrators can configure these rules further based on specific requirements.

When check_rule is defined, it expects one or more rule patterns as its argument(s). Each rule splits the input into manageable components and evaluates them against the incoming request's data (e.g., URI, headers, or body). If a match against a rule is found, the module can trigger a defensive response, such as blocking the request or routing it differently, thereby providing an essential layer of security. This behavior supports organizations in preventing inadvertent exposure to critical vulnerabilities, creating a robust defense against common web attacks.

Additionally, as this directive forms part of a security-focused setup, it emphasizes the need for ongoing management; over time, as legitimate traffic patterns may evolve, administrators should regularly review and adjust the rules to diminish false positives and enhance the site's usability while retaining its security.

Config Example

location /submit {
    check_rule "