MainRule

MainRule directive defines rules for filtering out malicious input in HTTP requests.

SyntaxMainRule string;
Defaultnone
Contexthttp
Arguments1+

Description

The MainRule directive in the NGINX Anti XSS & SQL Injection module (Naxsi) enables administrators to specify one or more rules that serve to protect against common web vulnerabilities by filtering incoming requests. This directive operates under the principle of 'deny by default,' meaning that if a request does not match existing rules, it will be rejected. A typical implementation may involve whitelisting legitimate requests through manually crafted rules or by employing an auto-learning feature of Naxsi that builds rules based on observed web traffic.

When you configure MainRule, you can input multiple rule arguments, allowing for a fine-tuned approach to security. Each argument corresponds to a specific allowable pattern in the request, enabling the filtering of harmful content, such as SQL injection attempts or XSS payloads. It is crucial that users carefully analyze the logs generated by Naxsi to ensure that legitimate request patterns are not incorrectly filtered out. The administrator has the responsibility to continuously update and maintain the rules to reflect changing application needs and web attack patterns.

Config Example

MainRule "@block a;";
MainRule "@block x;";

Ensure that the rules defined are accurate and do not block legitimate traffic.

Overly broad rules may lead to false positives, causing legitimate requests to be ignored.

The configuration may require regular updates based on application changes to prevent unintended blocking.

← Back to all directives