MainAndEventModules

= Nginx documentation = The nginx directives always end with a  or is enclosed between   and   user and   or   group or the   and   from the   script.

timer_resolution 100ms; The directive allows to decrease number gettimeofday syscalls. By default gettimeofday is called after each return from kevent, epoll, /dev/poll, select, poll.

But if you need an exact time in logs when logging $upstream_response_time, or $msec variables, then you should use.

pid /var/log/nginx.pid; The pid-file. It can be used for the kill-command to send signals to nginx, eg: to reload the config:

lock_file /var/log/lock_file; nginx uses accept mutex to serialize accept syscalls. If nginx is built by gcc, Intel C++, or SunPro C++ compilers on i386, amd64, sparc64, and ppc64, then nginx uses the atomic instructions to implement the mutex. In other cases the lock file would be used.

worker_processes NUM; nginx has the ability to use more then on worker process for several reasons:

The  and   from the event sections allows you to calculate   value:
 * 1)  to use SMP,
 * 2)  to decrease latency when workers blockend on disk I/O,
 * 3)  to limit number of connections per process when select/poll is used.

max_clients = worker_processes * worker_connections

debug_points [stop|abort] ; There are some assertion points inside nginx that allow to stop nginx to attach the debugger, or to abort and to create the core file.

worker_priority [-] NUM; With this option you can give to all worker processes the priority (nice) you need/wish, it calls setpriority.

worker_cpu_affinity CPUMASK [CPUMASK] ...; Linux only.

With this option you can bind the worker process to a CPU, it calls sched_setaffinity. For example,

worker_proceses    4; worker_cpu_affinity 0001 0010 0100 1000; Bind each worker process to one CPU only.

worker_proceses    2; worker_cpu_affinity 0101 1010; Bind the first worker to CPU0/CPU2, bind the second worker to CPU1/CPU3. This is suitable for HTT.

worker_rlimit_nofile FDLIMITS; Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_core SIZE; Maximum size of core file per worker;

worker_rlimit_sigpending ; (Since Linux 2.6.8) Specifies the limit on the number of signals that may be queued for the real user ID of the calling process.

working_directory DIR; This is the working directory for the workers. It's used for core files only. nginx uses absolute paths only, all relative paths in configuration files are relative to.

error_log LOGFILE [ debug | info | notice | warn | error | crit ] ; error_log LOGFILE [ debug_core | debug_alloc | debug_mutex | debug_event ]: | debug_http | debug_imap ; The debug options are only useful if you have added the  flag to the   script.

include FILE; You can include any configuration files for what ever purpose you want ;-)

The events { } section
worker_connections NUM; The worker_connections and worker_proceses from the main section allows you to calculate maxclients value:

max_clients = worker_processes * worker_connections

---

use [ kqueue | rtsig | epoll | /dev/poll | select | poll ] ; If you have more than one event-model specified at the  script, then you can tell nginx which one do you want to use. By default nginx looks for the most suitable method for your OS at  time.

rtsig_signo nginx uses two signals when the  method is used. The directive specified the first signal number. The second is plus 1. By default  is SIGRTMIN+10 (40).

rtsig_overflow_events rtsig_overflow_test rtsig_overflow_threshold The directives specifies how to handle rtsig queue overflows. When overflow occurred nginx flushes rtsig queue, then it handles events switching between poll and rtsig. poll handles consecutively all unhandled events, while rtsig periodicaly drains queue to prevent a new overflow. When overflow is handled completely, nginx switches to rtsig method again.

The rtsig_overflow_events specifies the number of events to be passed via poll. The default is 16.

The rtsig_overflow_test specifies after which number of events handled by poll nginx will drains rtsig queue. The default is 32.

The rtsig_overflow_threshold works in Linux 2.4.x only. Before to drain rtsig queue nginx looks in a kernel how the queue is filled up

The default is 1/10. "rtsig_overflow_threshold 3" means 1/3.

devpoll_changes devpoll_events kqueue_changes kqueue_events epoll_events The directives specify how many events may be passed to/from kernel, using appropriate method. The default  values are 32, the rest are 512.

multi_accept [ on | off ] ; tries to accept as many connections as possible after nginx gets notification about a new connection.

accept_mutex [ on | off ] ; nginx uses accept mutex to serialize accept syscalls.

accept_mutex_delay Nms; If a worker process does not have accept mutex it will try to aquire it at least after this delay. By default delay is 500ms.

debug_connection IP; Since 0.3.54 this option support CIDR address format This option gives you the ability to write debug log only for the clients of this IP/NET. Several different directives are possible.

ssl_engine OPENSSLENGINE; Here you can set your preferred openssl engine if any available. You can figure out which one do you have with the commandline tool:

For example:

$ openssl engine -t (cryptodev) BSD cryptodev engine
 * [ available ]

(dynamic) Dynamic engine loading support
 * [ unavailable ]