Configuration Files#

Angie uses a text-based configuration file. By default, this file is named angie.conf and is located according to the --conf-path build parameter, typically in the /etc/angie directory.

A configuration file generally consists of the following contexts:

  • events – General connection processing

  • http – HTTP traffic

  • mail – Mail traffic

  • stream – TCP and UDP traffic

Directives that are placed outside of these contexts are considered to be in the main context:

user angie; # a directive in the 'main' context

events {

    # configuration of connection processing
}

http {

    # Configuration specific to HTTP and affecting all virtual servers

    server {

        # configuration of HTTP virtual server 1
        location /one {

            # configuration for processing URIs starting with '/one'
        }
        location /two {

            # configuration for processing URIs starting with '/two'
        }
    }

    server {

        # configuration of HTTP virtual server 2
    }
}

stream {

    # Configuration specific to TCP/UDP and affecting all virtual servers
    server {

        # configuration of TCP virtual server 1
    }
}

To simplify configuration management, we recommend using the include directive in the main angie.conf file to reference the contents of feature-specific files:

include /etc/angie/http.d/*.conf;
include /etc/angie/stream.d/*.conf;

Inheritance#

In general, a child context (one that is contained within another context, which is considered its parent) inherits the settings of directives defined at the parent level. Some directives can appear in multiple contexts; in such cases, you can override the settings inherited from the parent by including the directive in the child context.

Syntax#

Measurement Units#

Sizes can be specified in bytes (no suffix), kilobytes (suffixes k and K), or megabytes (suffixes m and M), for example, "1024" (bytes), "8k", "1m".

Time intervals can be specified in milliseconds, seconds, minutes, hours, days, and so on, using the following suffixes:

ms

Milliseconds

s

Seconds

m

Minutes

h

Hours

d

Days

w

Weeks

M

Months (assumed equal to 30 days)

y

Years (assumed equal to 365 days)

Multiple units can be combined in a single value by specifying them in order from the most significant to the least significant, optionally separated by whitespace. For example, "1h 30m" specifies the same duration as "90m" or "5400s". A value without a suffix is interpreted as seconds. It is recommended to always specify a suffix.

Some time intervals can only be specified with second-level resolution.

Directives#

Each directive consists of a name and a set of parameters. If any part of a directive needs to contain spaces, it should be enclosed in quotes or escape the spaces:

add_header X-MyHeader "foo bar";
add_header X-MyHeader foo\ bar;

If a named parameter needs spaces and you use quotes, its name must be enclosed in quotes as well:

server example.com "sid=server 1";

Setting up Hashes#

To efficiently process static sets of data, such as server names, the map directive values, MIME types, and request header names, Angie utilizes hash tables. During startup and each reconfiguration, Angie determines the optimal size for these hash tables to ensure that the bucket size, which stores keys with identical hash values, does not exceed the configured parameter (hash bucket size). The table size is measured in buckets and is adjusted until it exceeds the hash max size parameter. Most hash tables have corresponding directives to adjust these parameters, such as server_names_hash_max_size and server_names_hash_bucket_size for server names.

The hash bucket size parameter is aligned to a multiple of the processor's cache line size. This alignment enhances key search efficiency on modern processors by reducing the number of memory accesses. If the hash bucket size is equal to one cache line size, the maximum number of memory accesses during a key search will be two: one to compute the bucket address and another to search inside the bucket. Therefore, if Angie indicates that either the hash max size or hash bucket size should be increased, start by increasing the hash max size.

Reloading Configuration#

To apply changes to the configuration file, it must be reloaded. You can either restart the Angie process with a configuration syntax check beforehand:

$ sudo angie -t && sudo service angie restart

Alternatively, you can reload the service to apply the new configuration without interrupting the processing of current requests:

$ sudo angie -t && sudo service angie reload