=encoding utf-8 =head1 NAME ngx_core_module - Core functionality =head1 Example Configuration user www www; worker_processes 2; error_log /var/log/nginx-error.log info; events { use kqueue; worker_connections 2048; } ... =head1 Directives =head2 accept_mutex B accept_mutex I E C> B I B I If C 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. B There is no need to enable C on systems that support the L flag (1.11.3) or when using L. B Prior to version 1.11.3, the default value was C. =head2 accept_mutex_delay B accept_mutex_delay I>> B I<500ms> B I If L 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. =head2 daemon B daemon I E C> B I B I
Determines whether nginx should become a daemon. Mainly used during development. =head2 debug_connection B debug_connection I< I> E I> E C> B I Enables debugging log for selected client connections. Other connections will use logging level set by the L 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 “C” 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:; ... } B For this directive to work, nginx needs to be built with C<--with-debug>, see “L”. =head2 debug_points B debug_points I E C> B I
This directive is used for debugging. When internal error is detected, e.g. the leak of sockets on restart of working processes, enabling C leads to a core file creation (C) or to stopping of a process (C) for further analysis using a system debugger. =head2 env B env I>[=I>]> B I B I
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: =over =item * inherited during a L of an executable file; =item * used by the L module; =item * used by worker processes. One should bear in mind that controlling system libraries in this way is not always possible as it is common for libraries to check variables only during initialization, well before they can be set using this directive. An exception from this is an above mentioned L of an executable file. =back The TZ variable is always inherited and available to the L module, unless it is configured explicitly. Usage example: env MALLOC_OPTIONS; env PERL5LIB=/data/site/modules; env OPENSSL_ALLOW_PROXY_CERTS=1; B The NGINX environment variable is used internally by nginx and should not be set directly by the user. =head2 error_log B error_log I> [I>]> B Ierror.log error> B I
B I B I B I B I B I Configures logging. Several logs can be specified on the same configuration level (1.5.2). If on the C
configuration level writing a log to a file is not explicitly defined, the default file will be used. The first parameter defines a I> that will store the log. The special value C selects the standard error file. Logging to L can be configured by specifying the “C” prefix. Logging to a L can be configured by specifying the “C” prefix and buffer I>, and is generally used for debugging (1.7.11). The second parameter determines the I> of logging, and can be one of the following: C, C, C, C, C, C, C, or C. 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 C will cause C, C, C, and C messages to be logged. If this parameter is omitted then C is used. B For C logging to work, nginx needs to be built with C<--with-debug>, see “L”. B The directive can be specified on the C level starting from version 1.7.11, and on the C level starting from version 1.9.0. =head2 events events { B<...> } B I
Provides the configuration file context in which the directives that affect connection processing are specified. =head2 include B include I> E I>> Includes another I>, or files matching the specified I>, into configuration. Included files should consist of syntactically correct directives and blocks. Usage example: include mime.types; include vhosts/*.conf; =head2 load_module B load_module I>> B I
This directive appeared in version 1.9.11. Loads a dynamic module. Example: load_module modules/ngx_mail_module.so; =head2 lock_file B lock_file I>> B Inginx.lock> B I
nginx uses the locking mechanism to implement L and serialize access to shared memory. On most systems the locks are implemented using atomic operations, and this directive is ignored. On other systems the “lock file” mechanism is used. This directive specifies a prefix for the names of lock files. =head2 master_process B master_process I E C> B I B I
Determines whether worker processes are started. This directive is intended for nginx developers. =head2 multi_accept B multi_accept I E C> B I B I If C is disabled, a worker process will accept one new connection at a time. Otherwise, a worker process will accept all new connections at a time. B The directive is ignored if L connection processing method is used, because it reports the number of new connections waiting to be accepted. =head2 pcre_jit B pcre_jit I E C> B I B I
This directive appeared in version 1.1.12. Enables or disables the use of “just-in-time compilation” (PCRE JIT) for the regular expressions known by the time of configuration parsing. PCRE JIT can speed up processing of regular expressions significantly. B The JIT is available in PCRE libraries starting from version 8.20 built with the C<--enable-jit> configuration parameter. When the PCRE library is built with nginx (C<--with-pcre=>), the JIT support is enabled via the C<--with-pcre-jit> configuration parameter. =head2 pid B pid I>> B Inginx.pid> B I
Defines a I> that will store the process ID of the main process. =head2 ssl_engine B ssl_engine I>> B I
Defines the name of the hardware SSL accelerator. B The module may be dynamically loaded by OpenSSL during configuration testing. =head2 ssl_object_cache_inheritable B ssl_object_cache_inheritable I E C> B I B I
This directive appeared in version 1.27.4. If enabled, SSL objects (SSL certificates, secret keys, trusted CA certificates, CRL lists) will be inherited across configuration reloads. SSL objects loaded from a file are inherited if the modification time and file index has not been changed since the previous configuration load. Secret keys specified as C are never inherited. Secret keys specified as C are always inherited. B SSL objects loaded from variables cannot be inherited. Example: ssl_object_cache_inheritable on; http { ... server { ... ssl_certificate example.com.crt; ssl_certificate_key example.com.key; } } =head2 thread_pool B thread_pool I< I> C=I> [C=I>]> B I B I
This directive appeared in version 1.7.11. Defines the I> and parameters of a thread pool used for multi-threaded reading and sending of files L worker processes. The C parameter defines the number of threads in the pool. In the event that all threads in the pool are busy, a new task will wait in the queue. The C parameter limits the number of tasks allowed to be waiting in the queue. By default, up to 65536 tasks can wait in the queue. When the queue overflows, the task is completed with an error. =head2 timer_resolution B timer_resolution I>> B I
Reduces timer resolution in worker processes, thus reducing the number of C system calls made. By default, C is called each time a kernel event is received. With reduced resolution, C is only called once per specified I>. Example: timer_resolution 100ms; Internal implementation of the interval depends on the method used: =over =item * the C filter if C is used; =item * C if C is used; =item * C otherwise. =back =head2 use B use I>> B I Specifies the L I> to use. There is normally no need to specify it explicitly, because nginx will by default use the most efficient method. =head2 user B user I> [I>]> B I B I
Defines I> and I> credentials used by worker processes. If I> is omitted, a group whose name equals that of I> is used. =head2 worker_aio_requests B worker_aio_requests I>> B I<32> B I This directive appeared in version 1.1.4. This directive appeared in version 1.0.7. When using L with the L connection processing method, sets the maximum I> of outstanding asynchronous IEO operations for a single worker process. =head2 worker_connections B worker_connections I>> B I<512> B I Sets the maximum number of simultaneous connections that can be opened by a worker process. It should be kept in mind that this number includes all connections (e.g. connections with proxied servers, among others), not only connections with clients. Another consideration is that the actual number of simultaneous connections cannot exceed the current limit on the maximum number of open files, which can be changed by L. =head2 worker_cpu_affinity B worker_cpu_affinity I> ...> B worker_cpu_affinity I [I>]> B I
Binds worker processes to the sets of CPUs. Each CPU set is represented by a bitmask of allowed CPUs. There should be a separate set defined for each of the worker processes. By default, worker processes are not bound to any specific CPUs. For example, worker_processes 4; worker_cpu_affinity 0001 0010 0100 1000; binds each worker process to a separate CPU, while worker_processes 2; worker_cpu_affinity 0101 1010; binds the first worker process to CPU0ECPU2, and the second worker process to CPU1ECPU3. The second example is suitable for hyper-threading. The special value C (1.9.10) allows binding worker processes automatically to available CPUs: worker_processes auto; worker_cpu_affinity auto; The optional mask parameter can be used to limit the CPUs available for automatic binding: worker_cpu_affinity auto 01010101; B The directive is only available on FreeBSD and Linux. =head2 worker_priority B worker_priority I>> B I<0> B I
Defines the scheduling priority for worker processes like it is done by the C command: a negative I> means higher priority. Allowed range normally varies from -20 to 20. Example: worker_priority -10; =head2 worker_processes B worker_processes I> E C> B I<1> B I
Defines the number of worker processes. The optimal value depends on many factors including (but not limited to) the number of CPU cores, the number of hard disk drives that store data, and load pattern. When one is in doubt, setting it to the number of available CPU cores would be a good start (the value “C” will try to autodetect it). B The C parameter is supported starting from versions 1.3.8 and 1.2.5. =head2 worker_rlimit_core B worker_rlimit_core I>> B I
Changes the limit on the largest size of a core file (C) for worker processes. Used to increase the limit without restarting the main process. =head2 worker_rlimit_nofile B worker_rlimit_nofile I>> B I
Changes the limit on the maximum number of open files (C) for worker processes. Used to increase the limit without restarting the main process. =head2 worker_shutdown_timeout B worker_shutdown_timeout I>> B I
This directive appeared in version 1.11.11. Configures a timeout for a graceful shutdown of worker processes. When the I> expires, nginx will try to close all the connections currently open to facilitate shutdown. =head2 working_directory B working_directory I>> B I
Defines the current working directory for a worker process. It is primarily used when writing a core-file, in which case a worker process should have write permission for the specified directory.