Core functionality
Example Configuration
user www www;
worker_processes 2;
error_log /var/log/nginx-error.log info;
events {
use kqueue;
worker_connections 2048;
}
...
Directives
Syntax:
accept_mutex on | off;
Default:
accept_mutex off;
Context:
events
If accept_mutex is enabled, worker processes will accept new connections by turn. Otherwise, all worker processes will be notified about new connections, and if volume of new connections is low, some of the worker processes may just waste system resources.
There is no need to enable accept_mutex on systems that support the flag (1.11.3) or when using . Prior to version 1.11.3, the default value was on.
Syntax:
accept_mutex_delay time;
Default:
accept_mutex_delay 500ms;
Context:
events
If is enabled, specifies the maximum time during which a worker process will try to restart accepting new connections if another worker process is currently accepting new connections.
Syntax:
daemon on | off;
Default:
daemon on;
Context:
main
Determines whether nginx should become a daemon. Mainly used during development.
Syntax:
debug_connection
address |
CIDR |
unix:;
Default:
—
Context:
events
Enables debugging log for selected client connections. Other connections will use logging level set by the directive. Debugged connections are specified by IPv4 or IPv6 (1.3.0, 1.2.1) address or network. A connection may also be specified using a hostname. For connections using UNIX-domain sockets (1.3.0, 1.2.1), debugging log is enabled by the “unix:” parameter.
events { debug_connection 127.0.0.1; debug_connection localhost; debug_connection 192.0.2.0/24; debug_connection ::1; debug_connection 2001:0db8::/32; debug_connection unix:; ... } For this directive to work, nginx needs to be built with --with-debug, see “A debugging log”.
Syntax:
debug_points abort | stop;
Default:
—
Context:
main
This directive is used for debugging.
When internal error is detected, e.g. the leak of sockets on restart of working processes, enabling debug_points leads to a core file creation (abort) or to stopping of a process (stop) for further analysis using a system debugger.
Syntax:
env variable[=value];
Default:
env TZ;
Context:
main
By default, nginx removes all environment variables inherited from its parent process except the TZ variable. This directive allows preserving some of the inherited variables, changing their values, or creating new environment variables. These variables are then:
The TZ variable is always inherited and available to the ngx_http_perl_module module, unless it is configured explicitly.
Usage example:
env MALLOC_OPTIONS; env PERL5LIB=/data/site/modules; env OPENSSL_ALLOW_PROXY_CERTS=1; The NGINX environment variable is used internally by nginx and should not be set directly by the user.
Syntax:
error_log file [level];
Default:
error_log logs/error.log error;
Context:
main, http, mail, stream, server, location
Configures logging. Several logs can be specified on the same level (1.5.2). If on the main configuration level writing a log to a file is not explicitly defined, the default file will be used.
The first parameter defines a file that will store the log. The special value stderr selects the standard error file. Logging to syslog can be configured by specifying the “syslog:” prefix. Logging to a can be configured by specifying the “memory:” prefix and buffer size, and is generally used for debugging (1.7.11).
The second parameter determines the level of logging, and can be one of the following: debug, info, notice, warn, error, crit, alert, or emerg. Log levels above are listed in the order of increasing severity. Setting a certain log level will cause all messages of the specified and more severe log levels to be logged. For example, the default level error will cause error, crit, alert, and emerg messages to be logged. If this parameter is omitted then error is used.
For debug logging to work, nginx needs to be built with --with-debug, see “A debugging log”. The directive can be specified on the stream level starting from version 1.7.11, and on the mail level starting from version 1.9.0.