NaxsiLogFile

The NaxsiLogFile directive specifies the file location where the Naxsi module will log security events related to XSS and SQL injection attempts.

Syntaxnaxsi_log_file path;
Defaultnone
Contexthttp, server, location, limit_except
Arguments1+

Description

The NaxsiLogFile directive in the NGINX Anti XSS & SQL Injection module is used to define the log file path that will capture the results of the security checks performed by Naxsi. This log file records the events where potential security threats, such as cross-site scripting (XSS) and SQL injection attacks, have been detected based on the rules defined in the Naxsi configuration. By logging these incidents, administrators can monitor and analyze attempted attacks against their web applications, allowing them to respond proactively to vulnerabilities.

The directive accepts a single argument representing the path of the log file. This path can be either absolute or relative, but it is important to ensure that the NGINX user has the appropriate permissions to write to the specified file. If the log file does not exist, it will be created automatically when NGINX starts up and begins receiving requests. The logging format and the level of verbosity can be influenced by other configuration directives, allowing for tailored logging that meets the specific needs of the deployment.

To implement this directive, it can be included in various contexts: http, server, location, or limit_except, which provides flexibility in managing logging for different parts of your web application. The use of this directive is essential for maintaining security over web applications that are susceptible to injection attacks, thereby supporting the overall objective of the Naxsi module.

Config Example

http {
    naxsi_log_file /var/log/nginx/naxsi.log;
}

Ensure the log file path is writable by the NGINX user to avoid permission errors.

Be cautious of large log files that may grow quickly; implement log rotation to manage file size.

In a production environment, ensure sensitive data is not logged to avoid security risks.

← Back to all directives