denied_url

The `denied_url` directive specifies one or more URL patterns that are to be blocked by the NGINX Anti XSS & SQL Injection module.

Syntaxdenied_url string | regex;
Defaultnone
Contexthttp, server, location, limit_except
Arguments1+

Description

The denied_url directive in the NGINX Anti XSS & SQL Injection module (NAXSI) is a powerful feature that allows administrators to define specific URL patterns that should be denied access. By using this directive, you can add one or more patterns that the application considers potentially harmful or indicative of an attack, such as SQL injection or cross-site scripting (XSS) attempts. The directive can be placed in various contexts, including http, server, location, or limit_except, providing flexibility in specifying the scope of the denial.

When a request is made, NAXSI checks the requested URL against the patterns defined in the denied_url directive. If a match is found, NAXSI will block the request and can respond accordingly, often generating an error message or triggering logging mechanisms. The directive accepts one or more arguments, each representing a URL pattern. These patterns must be carefully crafted to avoid unintentionally blocking legitimate requests while still safeguarding the application from common attack vectors. Administrators can leverage NAXSI's logging capabilities to track blocked requests and refine their rules by whitelisting legitimate user behavior. Configuring denied_url properly is essential for ensuring website security without impairing usability.

Config Example

server {
    location / {
        denied_url /evil-path;
        denied_url /sqli_endpoint;
    }
}

Ensure that patterns do not accidentally match legitimate URLs, leading to unnecessary blocks.

Be cautious with regex patterns, as complex expressions can have performance implications.

Test configurations in a staging environment before deploying to production to avoid unintended disruptions.

← Back to all directives