Core Module#
The module provides essential functionality and configuration directives
necessary for the basic operation of the server,
and handles critical tasks such as managing worker processes,
configuring event-driven models,
and processing incoming connections and requests.
It includes key directives for setting up the main process, error
logging, and controlling the behavior of the server at a low level. When Note There is no need to enable If accept_mutex is enabled,
this directive specifies the maximum time
a worker process will wait
to continue accepting new connections
while another worker process is already handling new connections. Determines whether Angie should run as a daemon.
This is primarily used during development. Enables debugging logs for specific client connections.
Other connections will use the logging level
set by the error_log directive.
You can specify connections by IPv4 or IPv6 address, network, or hostname.
For connections using UNIX domain sockets,
use the Important For this directive to work,
Angie must be built with debugging log enabled. This directive is used for debugging. When an internal error occurs,
such as a socket leak during worker process restarts,
enabling By default,
Angie removes all environment variables inherited from its parent process
except for the These variables are then: Inherited during a
live upgrade of an executable file Used by the Perl module Available to worker processes Note that controlling system libraries in this way may not always be effective,
as libraries often check variables only during initialization,
which occurs before this directive takes effect.
The Example: Note The Default main, http, mail, stream, server, location Configures logging,
allowing multiple logs to be specified at the same configuration level.
If a log file is not explicitly defined at the The first parameter specifies the file to store the log.
The special value The second parameter sets the logging level, which can be one of the following:
Setting Levels Captured If this parameter is omitted,
Important For the Provides the configuration file context for directives
that affect connection processing. Includes another file, or files that match the specified mask,
into the configuration.
The included files must contain syntactically correct directives and blocks. Example: Loads a dynamic module from the specified file.
If a relative path is provided, it is interpreted based on the
Example: Default main Angie uses a locking mechanism to implement accept_mutex
and serialize access to shared memory.
On most systems, locks are managed using atomic operations,
making this directive unnecessary.
On certain systems, however, an alternative lock file mechanism is used.
This directive sets a prefix for lock file names. Determines whether worker processes are started.
This directive is intended for Angie developers. A worker process will accept all new connections simultaneously. A worker process will accept one new connection at a time. Note This directive is ignored
if the kqueue connection processing method is used,
as it provides the number of new connections ready to be accepted. Enables or disables "just-in-time compilation" (PCRE JIT)
for regular expressions known at the time of configuration parsing. PCRE JIT can significantly accelerate regular expression processing. Important JIT is available in PCRE libraries from version 8.20,
provided they are built with the Default main Specifies the file that will store the ID of the Angie main process.
The file is created atomically, which ensures its contents are always correct.
The Note If the file setting is modified during reconfiguration
but points to a symlink of the previous PID file,
the file will not be recreated. Specifies the name of the hardware SSL accelerator. Default main Defines the name and parameters of a thread pool
used for multi-threaded file reading and sending,
without blocking worker processes. The If all threads are busy, new tasks will wait in the queue.
The Reduces timer resolution in worker processes,
thereby decreasing the frequency of Example: The internal implementation of the interval depends on the method used: Specifies the connection processing method to use.
Typically, there is no need to specify it explicitly,
as Angie defaults to the most efficient method. Defines the user and group credentials for worker processes
(see also the build options).
If only the user is set,
the specified user name is also used for the group. When using aio with the epoll connection processing method,
sets the maximum number of outstanding asynchronous I/O operations
for a single worker process. Sets the maximum number of simultaneous connections a worker process can open. Note that this number includes all connections,
such as those with proxied servers, not just client connections.
Additionally, the actual number of simultaneous connections
cannot exceed the system's limit on open files,
which can be adjusted using worker_rlimit_nofile. Binds worker processes to specific sets of CPUs.
Each CPU set is represented by a bitmask indicating allowed CPUs.
A separate set should be defined for each worker process.
By default, worker processes are not bound to any specific CPUs. For example: This configuration binds each worker process to a separate CPU. Alternatively: This binds the first worker process to CPU0 and CPU2,
and the second worker process to CPU1 and CPU3.
This setup is suitable for hyper-threading. The special value The optional mask parameter can be used
to limit the CPUs available for automatic binding: Important This directive is only available on FreeBSD and Linux. Defines the scheduling priority for worker processes,
similar to the nice command:
a negative number indicates higher priority.
The allowed range typically varies from -20 to 20. Example: Defines the number of worker processes. The optimal value depends on various factors, including the number of CPU cores,
the number of hard disk drives, and the load pattern.
If unsure, starting with the number of available CPU cores is recommended.
The value Changes the limit on the maximum size of a core file ( Changes the limit on the maximum number of open files ( Configures a timeout for the graceful shutdown of worker processes.
Once the time expires, Angie will attempt to close all active connections
to complete the shutdown process. A graceful shutdown is initiated by sending a QUIT signal to the master process, which tells the worker processes to
stop accepting new connections while allowing existing connections to complete.
Workers continue to process active requests until they finish, after which they
exit cleanly. If the connections remain open beyond
Defines the current working directory for a worker process.
This is primarily used for writing core files,
so the worker process must have write permissions for the specified directory.Configuration Example#
user www www;
worker_processes 2;
error_log /var/log/error.log info;
events {
use kqueue; worker_connections 2048;
}
Directives#
accept_mutex#
accept_mutex
is enabled,
worker processes will accept new connections in turn.
Without this setting, all worker processes are notified of new connections,
which can lead to inefficient use of system resources
if the volume of new connections is low.accept_mutex
on systems
that support the EPOLLEXCLUSIVE
flag
or when using the reuseport directive.accept_mutex_delay#
daemon#
debug_connection#
unix:
parameter to enable debugging logs.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:;
# ...
}
debug_points#
debug_points
will either create a core file (abort
)
or stop the process (stop
) for further analysis with a system debugger.env#
TZ
variable.
This directive allows you to preserve some inherited variables,
modify their values, or create new environment variables.TZ
variable is always inherited
and accessible to the Perl module
unless explicitly configured otherwise.env MALLOC_OPTIONS;
env PERL5LIB=/data/site/modules;
env OPENSSL_ALLOW_PROXY_CERTS=1;
ANGIE
environment variable is used internally by Angie
and should not be set directly by the user.error_log#
error_log
file [level];error_log logs/error.log error;
(the path depends on the --error-log-path
build option)main
configuration level,
the default file will be used.stderr
selects the standard error stream.
To configure logging to syslog,
use the "syslog:"
prefix.
To log to a cyclic memory buffer,
use the "memory:"
prefix followed by the buffer size;
this is typically used for debugging.debug
, info
, notice
, warn
, error
,
crit
, alert
, or emerg
.
These levels are listed in order of increasing severity.
Setting a log level will capture messages of equal and higher severity:debug
debug
, info
, notice
, warn
, error
,
crit
, alert
, emerg
info
info
, notice
, warn
, error
,
crit
, alert
, emerg
notice
notice
, warn
, error
,
crit
, alert
, emerg
warn
warn
, error
, crit
, alert
, emerg
error
error
, crit
, alert
, emerg
crit
crit
, alert
, emerg
alert
alert
, emerg
emerg
emerg
error
is used as the default logging level.debug
logging level to work,
Angie must be built with debugging log enabled.events#
include#
include mime.types;
include vhosts/*.conf;
load_module#
--prefix
build option. To verify the path:$ sudo angie -V
load_module modules/ngx_mail_module.so;
lock_file#
lock_file
file;lock_file logs/angie.lock;
(the path depends on the --lock-path
build option)master_process#
multi_accept#
on
off
pcre_jit#
--enable-jit
configuration option.
When Angie is built with the PCRE library (--with-pcre=
),
JIT support is enabled using the --with-pcre-jit
option.pid#
pid
file | off
;pid logs/angie.pid;
(the path depends on the --pid-path
build option)off
setting disables the creation of this file.ssl_engine#
thread_pool#
thread_pool
name threads=
number [max_queue=
number];thread_pool default threads=32 max_queue=65536;
threads
parameter specifies the number of threads in the pool.max_queue
parameter limits the number of tasks
that can wait in the queue.
By default, the queue can hold up to 65536 tasks.
When the queue overflows, new tasks are completed with an error.timer_resolution#
gettimeofday()
system calls.
By default, gettimeofday()
is called each time kernel events are queried.
With reduced resolution, it is called only once per the specified interval.timer_resolution 100ms;
use#
user#
worker_aio_requests#
worker_connections#
worker_cpu_affinity#
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
worker_processes 2;
worker_cpu_affinity 0101 1010;
auto
allows automatic binding of worker processes to available CPUs:worker_processes auto;
worker_cpu_affinity auto;
worker_cpu_affinity auto 01010101;
worker_priority#
worker_priority -10;
worker_processes#
auto
attempts to autodetect the optimal worker process number.worker_rlimit_core#
RLIMIT_CORE
)
for worker processes.
This allows increasing the limit without restarting the main process.worker_rlimit_nofile#
RLIMIT_NOFILE
)
for worker processes.
This allows increasing the limit without restarting the main process.worker_shutdown_timeout#
worker_shutdown_timeout
, Angie will forcefully close those
connections to finalize the shutdown.
Also, keepalive connections from clients are closed only if they remain inactive
for at least the duration of lingering_timeout.working_directory#