debug_connection

The `debug_connection` directive specifies which client connections should be logged for debugging purposes when using NGINX in debug mode.

Syntaxdebug_connection address;
Defaultnone
Contextevents
Arguments1

Description

The debug_connection directive allows users to specify IP addresses from which incoming connections will be logged specifically in the debug log. This directive is essential when troubleshooting issues in a NGINX instance, as it provides detailed insights into the processing of requests from designated clients. By default, without this directive, no IPs would receive enhanced logging, which is crucial for effective debugging.

When utilizing this directive, the specified IP can include single IP addresses or CIDR notation for subnets, making it flexible for various networking scenarios. The directive must be placed within the events context of the NGINX configuration as this is tied to connection handling. Detailed logs will include not only the standard request information but also additional debugging details that assist system administrators in identifying misconfigurations or connection anomalies.

It is important to note that having numerous debug connections can produce large log files, which may require operational management if enabled in a production environment. Therefore, it is typically used temporarily while diagnosing specific issues for a controlled set of users rather than across the entirety of incoming traffic.

In summary, the debug_connection directive provides a powerful tool for selectively enhancing logging on specific client connections, allowing for more effective debugging and system monitoring.

Config Example

events {
    debug_connection 192.168.1.0/24;
}

Ensure that the NGINX is compiled with debug support as this directive will have no effect otherwise.

Be cautious with logging levels and log file sizes, as enabling debug logging can quickly fill disk space.

Do not use this directive in production for all connections, as it can lead to excessive logging and performance issues.

← Back to all directives