<a id="http-core"></a>

# HTTP Module

The core HTTP module implements the basic functionality of an HTTP server: this
includes defining server blocks, configuring locations for request routing,
serving static files and controlling access, configuring redirects, supporting
keep-alive connections, and managing request and response headers.

The other modules in this section extend this functionality, allowing you to
flexibly configure and optimize the HTTP server for various scenarios and
requirements.

<a id="directives-55"></a>

## Directives

<a id="index-0"></a>

<a id="absolute-redirect"></a>

### absolute_redirect

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `absolute_redirect` `on` | `off`;   |
|------------------------------------------------------------------------------------------|-------------------------------------|
| Default                                                                                  | `absolute_redirect on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location              |

If disabled, redirects issued by Angie will be relative.

See also [server_name_in_redirect](#server-name-in-redirect) and [port_in_redirect](#port-in-redirect) directives.

<a id="index-1"></a>

<a id="aio"></a>

### aio

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `aio` `on` | `off` | `threads` [=pool];   |
|------------------------------------------------------------------------------------------|-------------------------------------------|
| Default                                                                                  | `aio off;`                                |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                    |

Enables or disables the use of asynchronous file I/O (AIO) on FreeBSD and Linux:

```nginx
location /video/ {
  aio            on;
  output_buffers 1 64k;
}
```

On FreeBSD, AIO can be used starting from FreeBSD 4.3. Prior to FreeBSD 11.0, AIO can either be linked statically into a kernel:

```nginx
options VFS_AIO
```

or loaded dynamically as a kernel loadable module:

```nginx
kldload aio
```

On Linux, AIO can be used starting from kernel version 2.6.22. Also, it is necessary to enable [directio](#directio), or otherwise reading will be blocking:

```nginx
location /video/ {
  aio            on;
  directio       512;
  output_buffers 1 128k;
}
```

On Linux, [directio](#directio) can only be used for reading blocks that are aligned on 512-byte boundaries (or 4K for XFS). File's unaligned end is read in blocking mode. The same holds true for byte range requests and for FLV requests not from the beginning of a file: reading of unaligned data at the beginning and end of a file will be blocking.

When both AIO and [sendfile](#sendfile) are enabled on Linux, AIO is used for files that are larger than or equal to the size specified in the [directio](#directio) directive, while [sendfile](#sendfile) is used for files of smaller sizes or when [directio](#directio) is disabled:

```nginx
location /video/ {
  sendfile       on;
  aio            on;
  directio       8m;
}
```

Finally, files can be read and [sent](#sendfile) using multi-threading, without blocking a worker process:

```nginx
location /video/ {
  sendfile       on;
  aio            threads;
}
```

Read and send file operations are offloaded to threads of the specified [pool](https://en.angie.software//angie/docs/configuration/modules/core.md#thread-pool). If the pool name is omitted, the pool with the name "default" is used. The pool name can also be set with variables:

```nginx
aio threads=pool$disk;
```

Using `aio on` requires building with the `--with-file-aio`
configuration parameter. Using `aio threads` requires building with the
`--with-threads` parameter.

Currently, multi-threading is compatible only with the [epoll](https://en.angie.software//angie/docs/configuration/processing.md#epoll),
[kqueue](https://en.angie.software//angie/docs/configuration/processing.md#kqueue), and [eventport](https://en.angie.software//angie/docs/configuration/processing.md#eventport) methods.
Multi-threaded sending of files is only supported on Linux.

See also the [sendfile](#sendfile) directive.

<a id="index-2"></a>

<a id="aio-write"></a>

### aio_write

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `aio_write` `on` | `off`;   |
|------------------------------------------------------------------------------------------|-----------------------------|
| Default                                                                                  | `aio_write off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location      |

If [aio](#aio) is enabled, specifies whether it is used for writing files. Currently, this only works when using `aio threads` and is limited to writing temporary files with data received from proxied servers.

<a id="index-3"></a>

<a id="alias"></a>

### alias

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `alias` path;   |
|------------------------------------------------------------------------------------------|-----------------|
| Default                                                                                  | —               |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | location        |

Defines a replacement for the specified location. For example, with the following configuration:

```nginx
location /i/ {
  alias /data/w3/images/;
}
```

on request of `/i/top.gif`, the file /data/w3/images/top.gif will be sent.

The path value can contain variables, except [$document_root](#v-document-root) and [$realpath_root](#v-realpath-root).

If `alias` is used inside a location defined with a regular expression then such regular expression should contain captures and `alias` should refer to these captures, for example:

```nginx
location ~ ^/users/(.+\.(?:gif|jpe?g|png))$ {
  alias /data/w3/images/$1;
}
```

When location matches the last part of the directive's value:

```nginx
location /images/ {
  alias /data/w3/images/;
}
```

it is better to use the [root](#root) directive instead:

```nginx
location /images/ {
  root /data/w3;
}
```

<a id="index-4"></a>

<a id="auth-delay"></a>

### auth_delay

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `auth_delay` time;     |
|------------------------------------------------------------------------------------------|------------------------|
| Default                                                                                  | `auth_delay 0s;`       |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location |

Delays processing of unauthorized requests with 401 response code to prevent
timing attacks when access is limited by [password](https://en.angie.software//angie/docs/configuration/modules/http/http_auth_basic.md#http-auth-basic) or by
the [result of subrequest](https://en.angie.software//angie/docs/configuration/modules/http/http_auth_request.md#http-auth-request).

<a id="index-5"></a>

<a id="auto-redirect"></a>

### auto_redirect

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `auto_redirect` [`on` | `off` | `default`];   |
|------------------------------------------------------------------------------------------|-----------------------------------------------|
| Default                                                                                  | `auto_redirect default;`                      |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                        |

Controls the [redirection](#location-redirect) behavior
when a prefix location ends with a slash:

```nginx
location /prefix/ {
    auto_redirect on;
}
```

Here, a request for `/prefix` causes a redirect to `/prefix/`.

The value `on` explicitly enables redirection,
while `off` disables it.
When set to `default`, redirection is enabled only
if the location processes requests with [api](https://en.angie.software//angie/docs/configuration/modules/http/http_api.md#a-api), [proxy_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_proxy.md#proxy-pass),
[fastcgi_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_fastcgi.md#fastcgi-pass), [uwsgi_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_uwsgi.md#uwsgi-pass), [scgi_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_scgi.md#scgi-pass), [memcached_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_memcached.md#memcached-pass),
or [grpc_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_grpc.md#grpc-pass).

<a id="index-6"></a>

<a id="chunked-transfer-encoding"></a>

### chunked_transfer_encoding

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `chunked_transfer_encoding` `on` | `off`;   |
|------------------------------------------------------------------------------------------|---------------------------------------------|
| Default                                                                                  | `chunked_transfer_encoding on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                      |

Allows disabling chunked transfer encoding in HTTP/1.1. It may come in handy when using a software failing to support chunked encoding despite the standard's requirement.

<a id="index-7"></a>

<a id="client"></a>

### client

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client` { ... }   |
|------------------------------------------------------------------------------------------|--------------------|
| Default                                                                                  | —                  |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http               |

Creates a special `client` context for processing internal HTTP requests
that Angie performs on its own without external client involvement.

The `client` context isolates service traffic
from various Angie modules from user traffic,
allowing additional control over it.
Within this context, only named locations
(with the `@` prefix) can be defined;
they are not accessible for external HTTP requests
and can only be called programmatically through internal server mechanisms.

The `client` context is used for:

- sending requests to the certificate authority in the [ACME](https://en.angie.software//angie/docs/configuration/modules/http/http_acme.md#http-acme) module
  via the predefined `location @acme`,
  which can be additionally configured
  using directives from the [Proxy](https://en.angie.software//angie/docs/configuration/modules/http/http_proxy.md#http-proxy) module;
- requests to the Docker API in the [Docker](https://en.angie.software//angie/docs/configuration/modules/http/http_docker.md#http-docker) module
  via the predefined `location @docker_events`
  and `@docker_containers`,
  which can be additionally configured
  using directives from the [Proxy](https://en.angie.software//angie/docs/configuration/modules/http/http_proxy.md#http-proxy) module;
- health probes of proxied servers via [upstream_probe (PRO)](https://en.angie.software//angie/docs/configuration/modules/http/http_upstream_probe.md#u-upstream-probe);
- [sticky learn](https://en.angie.software//angie/docs/configuration/modules/stream/stream_upstream.md#s-u-sticky) mode with `remote_action`
  in the stream [Upstream](https://en.angie.software//angie/docs/configuration/modules/stream/stream_upstream.md#stream-upstream) module.

Support for multiple `client` blocks
allows grouping common settings for multiple `location` blocks
within each block,
which helps avoid configuration duplication.

Directives specified in each `client` block
are inherited only by `location` blocks explicitly declared within it.
In particular, this is why they do not affect the configuration of other modules
that implicitly use the `client` block for outgoing requests
(for example, [ACME](https://en.angie.software//angie/docs/configuration/modules/http/http_acme.md#http-acme) or [Docker](https://en.angie.software//angie/docs/configuration/modules/http/http_docker.md#http-docker)).

Example of using multiple `client` blocks
with settings inheritance:

```nginx
client {

    proxy_set_header Host docker.example.com;
    proxy_set_header Authorization "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==";

    location @docker_events {

    }

    location @docker_containers {

    }
}

client {

    proxy_method GET;
    proxy_set_header Host backend.example.com;
    proxy_set_header X-Real-IP $remote_addr;

    location @health_check {

        proxy_pass http://upstream-server/health;
    }
}
```

#### NOTE
The same directives are allowed here as in regular `location` blocks,
but only content handlers
(such as [js_content](https://en.angie.software//angie/docs/installation/external-modules/http_js.md#js-content) or [autoindex](https://en.angie.software//angie/docs/configuration/modules/http/http_autoindex.md#id1))
and variable handlers (such as [map](https://en.angie.software//angie/docs/configuration/modules/http/http_map.md#id1)),
as well as directives that generate requests themselves,
like `upstream_probe`, actually work.

Directives that operate at other
[request processing stages](https://en.angie.software//angie/docs/configuration/processing.md#http-sessions)
(such as [limit_req](https://en.angie.software//angie/docs/configuration/modules/http/http_api.md#limit-req), [auth_request](https://en.angie.software//angie/docs/configuration/modules/http/http_auth_request.md#id1),
[try_files](#try-files), image filters, XSLT, etc.)
do not work here.

<a id="index-8"></a>

<a id="client-body-buffer-size"></a>

### client_body_buffer_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client_body_buffer_size` size;   |
|------------------------------------------------------------------------------------------|-----------------------------------|
| Default                                                                                  | `client_body_buffer_size 8k|16k;` |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location            |

Sets the buffer size for reading the client request body. If the request body is larger than the buffer, the whole body or only its part is written to a [temporary file](#client-body-temp-path). By default, the buffer size is equal to two memory pages. On x86, other 32-bit platforms, and x86-64, this is 8K. On other 64-bit platforms, it is usually 16K.

<a id="index-9"></a>

<a id="client-body-in-file-only"></a>

### client_body_in_file_only

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client_body_in_file_only` `on` | `clean` | `off`;   |
|------------------------------------------------------------------------------------------|------------------------------------------------------|
| Default                                                                                  | `client_body_in_file_only off;`                      |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                               |

Determines whether to save the entire client request body to a file. This directive can be used during debugging, or when using the [$request_body_file](#v-request-body-file) variable, or the [$r->request_body_file](https://en.angie.software//angie/docs/configuration/modules/http/http_perl.md#p-r-request-body-file) method of the [Perl](https://en.angie.software//angie/docs/configuration/modules/http/http_perl.md#http-perl) module.

| `on`    | temporary files are not removed after request processing               |
|---------|------------------------------------------------------------------------|
| `clean` | allows the temporary files left after request processing to be removed |

<a id="index-10"></a>

<a id="client-body-in-single-buffer"></a>

### client_body_in_single_buffer

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client_body_in_single_buffer` `on` | `off`;   |
|------------------------------------------------------------------------------------------|------------------------------------------------|
| Default                                                                                  | `client_body_in_single_buffer off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                         |

Determines whether to save the entire client request body in a single buffer. The directive is recommended when using the [$request_body](#v-request-body) variable to reduce the number of copy operations involved.

<a id="index-11"></a>

<a id="client-body-temp-path"></a>

### client_body_temp_path

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client_body_temp_path` path [level1 [level2 [level3]]];                                                                                                                                       |
|------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Default                                                                                  | `client_body_temp_path client_body_temp;`<br/>(the path depends on the [build option](https://en.angie.software//angie/docs/installation/sourcebuild.md#paths) `--http-client-body-temp-path`) |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                                                                                                                                                                         |

Defines a directory for storing temporary files with client request bodies. Up to three-level subdirectory hierarchy can be used under the specified directory. For example, in the following configuration

```nginx
client_body_temp_path /spool/angie/client_temp 1 2;
```

a path to a temporary file might look like this:

```nginx
/spool/angie/client_temp/7/45/00000123457
```

<a id="index-12"></a>

<a id="client-body-timeout"></a>

### client_body_timeout

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client_body_timeout` time;   |
|------------------------------------------------------------------------------------------|-------------------------------|
| Default                                                                                  | `client_body_timeout 60s;`    |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location        |

Defines a timeout for reading client request body. The timeout is set only for a period between two successive read operations, not for the transmission of the whole request body. If a client does not transmit anything within this time, the request is terminated with the 408 (Request Time-out) error.

<a id="index-13"></a>

<a id="client-header-buffer-size"></a>

### client_header_buffer_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client_header_buffer_size` size;   |
|------------------------------------------------------------------------------------------|-------------------------------------|
| Default                                                                                  | `client_header_buffer_size 1k;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server                        |

Sets buffer size for reading client request header. For most requests, a buffer of 1K bytes is enough. However, if a request includes long cookies, or comes from a WAP client, it may not fit into 1K. If a request line or a request header field does not fit into this buffer then larger buffers, configured by the [large_client_header_buffers](#large-client-header-buffers) directive, are allocated.

If the directive is specified on the [server](#server) level, the value from the default server can be used. See the [Virtual server selection](https://en.angie.software//angie/docs/configuration/processing.md#request-processing) section for details.

<a id="index-14"></a>

<a id="client-header-timeout"></a>

### client_header_timeout

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client_header_timeout` time;   |
|------------------------------------------------------------------------------------------|---------------------------------|
| Default                                                                                  | `client_header_timeout 60s;`    |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server                    |

Defines a timeout for reading client request header. If a client does not transmit the entire header within this time, the request is terminated with the 408 (Request Time-out) error.

<a id="index-15"></a>

<a id="client-max-body-size"></a>

### client_max_body_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `client_max_body_size` size;   |
|------------------------------------------------------------------------------------------|--------------------------------|
| Default                                                                                  | `client_max_body_size 1m;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location         |

Sets the maximum allowed size of the client request body. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. Please be aware that browsers cannot correctly display this error.

| `0`   | disables checking of client request body size   |
|-------|-------------------------------------------------|

<a id="index-16"></a>

<a id="connection-pool-size"></a>

### connection_pool_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `connection_pool_size` size;        |
|------------------------------------------------------------------------------------------|-------------------------------------|
| Default                                                                                  | `connection_pool_size 256` | `512;` |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location              |

Allows accurate tuning of per-connection memory allocations. This directive has minimal impact on performance and should not generally be used. By default:

| `256` (bytes)   | on 32-bit platforms   |
|-----------------|-----------------------|
| `512` (bytes)   | on 64-bit platforms   |

<a id="index-17"></a>

<a id="default-type"></a>

### default_type

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `default_type` mime-type;   |
|------------------------------------------------------------------------------------------|-----------------------------|
| Default                                                                                  | `default_type text/plain;`  |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location      |

Defines the default MIME type of a response. Mapping of file name extensions to MIME types can be set with the [types](#types) directive.

<a id="index-18"></a>

<a id="directio"></a>

### directio

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `directio` size | `off`;   |
|------------------------------------------------------------------------------------------|----------------------------|
| Default                                                                                  | `directio off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location     |

Enables the use of the `O_DIRECT` flag (FreeBSD, Linux), the `F_NOCACHE` flag (macOS), or the `directio()` function (Solaris), when reading files that are larger than or equal to the specified size. The directive automatically disables the use of [sendfile](#sendfile) for a given request. It is recommended for serving large files:

```nginx
directio 4m;
```

or when using [aio](#aio) on Linux.

<a id="index-19"></a>

<a id="directio-alignment"></a>

### directio_alignment

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `directio_alignment` size;   |
|------------------------------------------------------------------------------------------|------------------------------|
| Default                                                                                  | `directio_alignment 512;`    |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location       |

Sets the alignment for [directio](#directio). In most cases, a 512-byte alignment is enough. However, when using XFS under Linux, it needs to be increased to 4K.

<a id="index-20"></a>

<a id="disable-symlinks"></a>

### disable_symlinks

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `disable_symlinks` `off`;<br/><br/>`disable_symlinks` `on` | `if_not_owner` [`from=`part];   |
|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
| Default                                                                                  | `disable_symlinks off;`                                                                      |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                                                                       |

Determines how symbolic links should be treated when opening files:

| `off`          | Symbolic links in the path are allowed and not checked. This is the default behavior.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `on`           | If any component of the path is a symbolic link, access to the file is denied.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `if_not_owner` | Access to the file is denied if any component of the path is a symbolic link, and the link and the object it points to have different owners.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `from=`part    | When checking symbolic links (parameters `on` and `if_not_owner`), all path components are usually checked. It is possible to skip checking symbolic links in the initial part of the path by additionally specifying the `from=part` parameter. In this case, symbolic links are checked only starting from the path component that follows the specified initial part. If the value is not an initial part of the checked path, the path is checked entirely, as if this parameter were not specified at all. If the value completely matches the file name, symbolic links are not checked. Variables can be used in the parameter value. |

Example:

```nginx
disable_symlinks on from=$document_root;
```

This directive is only available on systems that have the `openat()` and `fstatat()` interfaces. Such systems include modern versions of FreeBSD, Linux, and Solaris.

#### WARNING
The `on` and `if_not_owner` parameters add processing overhead.

On systems that do not support opening directories for search only, using these parameters requires worker processes to have read permissions for all directories being checked.

#### NOTE
The [AutoIndex](https://en.angie.software//angie/docs/configuration/modules/http/http_autoindex.md#http-autoindex), [Random Index](https://en.angie.software//angie/docs/configuration/modules/http/http_random_index.md#http-random-index), and [DAV](https://en.angie.software//angie/docs/configuration/modules/http/http_dav.md#http-dav) modules currently ignore this directive.

<a id="index-21"></a>

<a id="early-hints"></a>

### early_hints

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `early_hints` string ...;   |
|------------------------------------------------------------------------------------------|-----------------------------|
| Default                                                                                  | —                           |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location      |

Defines conditions under which the "103 Early Hints" response will be passed to a client. The response can be returned by proxied and gRPC backends. If at least one value of the string parameters is not empty and is not equal to `0` then the response will be passed:

```nginx
map $http_sec_fetch_mode $early_hints {
    navigate $http2$http3;
}

server {
    ...
    location / {
        early_hints $early_hints;
        proxy_pass http://example.com;
    }
}
```

<a id="index-22"></a>

<a id="error-page"></a>

### error_page

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `error_page` code ... [=[response]] uri;   |
|------------------------------------------------------------------------------------------|--------------------------------------------|
| Default                                                                                  | —                                          |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location, if in location     |

Defines the URI that will be shown for the specified errors. The uri value can use variables.

Example:

```nginx
error_page 404             /404.html;
error_page 500 502 503 504 /50x.html;
```

This causes an internal redirect to the specified uri with the client request method changed to "GET" (for all methods other than "GET" and "HEAD").

Furthermore, it is possible to change the response code to another using the syntax like `=response`, for example:

```nginx
error_page 404 =200 /empty.gif;
```

If an error response is processed by a proxied server or a FastCGI/uwsgi/SCGI/gRPC server, and the server may return different response codes (e.g., 200, 302, 401, or 404), it is possible to pass the code it returns:

```nginx
error_page 404 = /404.php;
```

If there is no need to change the URI and method during internal redirect, it is possible to pass error processing into a named `location`:

```nginx
location / {
  error_page 404 = @fallback;
}

location @fallback {
  proxy_pass http://backend;
}
```

#### NOTE
If an error occurs during the processing of uri, the response with the code of the last occurred error is returned to the client.

It is also possible to use URL redirects for error processing:

```nginx
error_page 403      http://example.com/forbidden.html;
error_page 404 =301 http://example.com/notfound.html;
```

In this case, by default, the response code 302 is returned to the client. It can only be changed to one of the redirect response codes (301, 302, 303, 307, and 308).

<a id="index-23"></a>

<a id="etag"></a>

### etag

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `etag` `on` | `off`;   |
|------------------------------------------------------------------------------------------|------------------------|
| Default                                                                                  | `etag on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location |

Enables or disables automatic generation of the `ETag` response header field for static resources.

<a id="index-24"></a>

<a id="d-http"></a>

### http

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `http` { ... }   |
|------------------------------------------------------------------------------------------|------------------|
| Default                                                                                  | —                |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | main             |

Provides the configuration file context in which the HTTP server directives are specified.

<a id="index-25"></a>

<a id="if-modified-since"></a>

### if_modified_since

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `if_modified_since` `off` | `exact` | `before`;   |
|------------------------------------------------------------------------------------------|---------------------------------------------------|
| Default                                                                                  | `if_modified_since exact;`                        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                            |

Specifies how to compare modification time of a response with the time in the `If-Modified-Since` request header field:

| `off`    | the response is always considered modified                                                                          |
|----------|---------------------------------------------------------------------------------------------------------------------|
| `exact`  | exact match                                                                                                         |
| `before` | modification time of the response is less than or equal to the time in the `If-Modified-Since` request header field |

<a id="index-26"></a>

<a id="ignore-invalid-headers"></a>

### ignore_invalid_headers

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `ignore_invalid_headers` `on` | `off`;   |
|------------------------------------------------------------------------------------------|------------------------------------------|
| Default                                                                                  | `ignore_invalid_headers on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server                             |

Controls whether Angie ignores header fields with invalid names. Valid names are composed of English letters, digits, hyphens, and possibly underscores (as controlled by the [underscores_in_headers](#underscores-in-headers) directive).

If the directive is specified on the [server](#server) level, the value from the default server can be used.

<a id="index-27"></a>

<a id="internal"></a>

### internal

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `internal;`   |
|------------------------------------------------------------------------------------------|---------------|
| Default                                                                                  | —             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | location      |

Specifies that a given `location` can only be used for internal requests. For external requests, the client error 404 (Not Found) is returned. Internal requests are the following:

* requests redirected by the [error_page](#error-page), [index](https://en.angie.software//angie/docs/configuration/modules/http/http_index.md#id1), [random_index](https://en.angie.software//angie/docs/configuration/modules/http/http_random_index.md#id1), and [try_files](#try-files) directives;
* requests redirected by the `X-Accel-Redirect` response header field from an upstream server;
* subrequests formed by the `include virtual` command of the [SSI](https://en.angie.software//angie/docs/configuration/modules/http/http_ssi.md#http-ssi) module, by the [Addition](https://en.angie.software//angie/docs/configuration/modules/http/http_addition.md#http-addition) module directives, and by [auth_request](https://en.angie.software//angie/docs/configuration/modules/http/http_auth_request.md#id1) and [mirror](https://en.angie.software//angie/docs/configuration/modules/http/http_mirror.md#id1) directives;
* requests changed by the [rewrite](https://en.angie.software//angie/docs/configuration/modules/http/http_rewrite.md#id4) directive.

Example:

```nginx
error_page 404 /404.html;

location = /404.html {
  internal;
}
```

Because the 404 error is returned in the context of a `location` with the `internal` directive, external requests can be redirected to a different location. This allows using the same prefix for both external and internal requests, but with different processing, for example:

```nginx
location /path {

    internal;
    error_page 404 =@external;

    proxy_pass https://internal;
}

location @external {

    proxy_pass https://external;
}
```

Here, an external request `GET /path` will be proxied to
`https://external/path`, while the same internal request will be proxied to
`https://internal/path`.

#### NOTE
To prevent looping that can occur with incorrect configurations, the number of internal redirects is limited to ten. When this limit is reached, the 500 (Internal Server Error) error is returned. In such cases, the `rewrite or internal redirection cycle` message can be seen in the error log.

<a id="index-28"></a>

<a id="keepalive-disable"></a>

### keepalive_disable

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `keepalive_disable` `none` | browser ...;   |
|------------------------------------------------------------------------------------------|---------------------------------------------|
| Default                                                                                  | `keepalive_disable msie6;`                  |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                      |

Disables keep-alive connections with misbehaving browsers. The browser parameters specify which browsers will be affected.

| `none`   | enables keep-alive connections with all browsers                                                               |
|----------|----------------------------------------------------------------------------------------------------------------|
| `msie6`  | disables keep-alive connections with old versions of MSIE, once a POST request is received                     |
| `safari` | disables keep-alive connections with Safari and Safari-like browsers on macOS and macOS-like operating systems |

<a id="index-29"></a>

<a id="keepalive-requests"></a>

### keepalive_requests

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `keepalive_requests` number;   |
|------------------------------------------------------------------------------------------|--------------------------------|
| Default                                                                                  | `keepalive_requests 1000;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location         |

Sets the maximum number of requests that can be served through one keep-alive connection. After the maximum number of requests are made, the connection is closed.

Periodic closing of connections is necessary to free per-connection memory allocations. Therefore, using too high maximum number of requests could result in excessive memory usage and is not recommended.

<a id="index-30"></a>

<a id="keepalive-time"></a>

### keepalive_time

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `keepalive_time` time;   |
|------------------------------------------------------------------------------------------|--------------------------|
| Default                                                                                  | `keepalive_time 1h;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location   |

Limits the maximum time during which requests can be processed through one keep-alive connection. After this time is reached, the connection is closed following the subsequent request processing.

<a id="index-31"></a>

<a id="keepalive-timeout"></a>

### keepalive_timeout

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `keepalive_timeout` timeout [header_timeout];   |
|------------------------------------------------------------------------------------------|-------------------------------------------------|
| Default                                                                                  | `keepalive_timeout 75s;`                        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                          |

| timeout   | sets a timeout during which a keep-alive client connection will stay open on the server side   |
|-----------|------------------------------------------------------------------------------------------------|
| `0`       | disables keep-alive client connections                                                         |

The second, *optional*, parameter sets a value in the `Keep‑Alive: timeout=time` header field in the response. The two parameters may differ.

The `Keep-Alive: timeout=time` header field is recognized by Mozilla and Konqueror. MSIE closes keep-alive connections by itself in about 60 seconds.

<a id="index-32"></a>

<a id="large-client-header-buffers"></a>

### large_client_header_buffers

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `large_client_header_buffers` number size;   |
|------------------------------------------------------------------------------------------|----------------------------------------------|
| Default                                                                                  | `large_client_header_buffers 4 8k;`          |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server                                 |

Sets the maximum number and size of buffers used for reading large client request header. A request line cannot exceed the size of one buffer, or the 414 (Request-URI Too Large) error is returned to the client. A request header field cannot exceed the size of one buffer as well, or the 400 (Bad Request) error is returned to the client. Buffers are allocated only on demand. By default, the buffer size is equal to 8K bytes. If after the end of request processing a connection is transitioned into the keep-alive state, these buffers are released.

If the directive is specified on the [server](#server) level, the value from the default server can be used.

<a id="index-33"></a>

<a id="limit-except"></a>

### limit_except

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `limit_except` method1 [method2...] { ... };   |
|------------------------------------------------------------------------------------------|------------------------------------------------|
| Default                                                                                  | —                                              |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | location                                       |

Limits allowed HTTP methods inside a location. The method parameter can be one of the
following: `GET`, `HEAD`, `POST`, `PUT`, `DELETE`,
`MKCOL`, `COPY`, `MOVE`, `OPTIONS`, `PROPFIND`,
`PROPPATCH`, `LOCK`, `UNLOCK`, or `PATCH`. Allowing the
`GET` method makes the `HEAD` method also allowed. Access to other methods
can be limited using the [Access](https://en.angie.software//angie/docs/configuration/modules/http/http_access.md#http-access) and
[Auth Basic](https://en.angie.software//angie/docs/configuration/modules/http/http_auth_basic.md#http-auth-basic) module directives:

```nginx
limit_except GET {
  allow 192.168.1.0/32;
  deny  all;
}
```

#### NOTE
The restriction in this example applies to all methods
**except** `GET` and `HEAD`.

<a id="index-34"></a>

<a id="limit-rate"></a>

### limit_rate

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `limit_rate` rate;                     |
|------------------------------------------------------------------------------------------|----------------------------------------|
| Default                                                                                  | `limit_rate 0;`                        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location, if in location |

Limits the rate of response transmission to a client. The rate is specified in bytes per second. The zero value disables rate limiting. The limit is set per a request, and so if a client simultaneously opens two connections, the overall rate will be twice as much as the specified limit.

Parameter value can contain variables. It may be useful in cases where rate should be limited depending on a certain condition:

```nginx
map $slow $rate {
  1     4k;
  2     8k;
}

limit_rate $rate;
```

Rate limit can also be set in the [$limit_rate](#v-limit-rate) variable, however, this method is not recommended:

```nginx
server {

  if ($slow) {
    set $limit_rate 4k;
  }

}
```

Rate limit can also be set in the `X-Accel-Limit-Rate` header field of a proxied server response. This capability can be disabled using the [proxy_ignore_headers](https://en.angie.software//angie/docs/configuration/modules/http/http_proxy.md#proxy-ignore-headers), [fastcgi_ignore_headers](https://en.angie.software//angie/docs/configuration/modules/http/http_fastcgi.md#fastcgi-ignore-headers), [uwsgi_ignore_headers](https://en.angie.software//angie/docs/configuration/modules/http/http_uwsgi.md#uwsgi-ignore-headers), and [scgi_ignore_headers](https://en.angie.software//angie/docs/configuration/modules/http/http_scgi.md#scgi-ignore-headers) directives.

<a id="index-35"></a>

<a id="limit-rate-after"></a>

### limit_rate_after

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `limit_rate_after` size;               |
|------------------------------------------------------------------------------------------|----------------------------------------|
| Default                                                                                  | `limit_rate_after 0;`                  |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location, if in location |

Sets the initial amount after which the further transmission of a response to a client will be rate limited. Parameter value can contain variables.

Example:

```nginx
location /flv/ {
 flv;
 limit_rate_after 500k;
 limit_rate       50k;
}
```

<a id="index-36"></a>

<a id="lingering-close"></a>

### lingering_close

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `lingering_close` `on` | `always` | `off`;   |
|------------------------------------------------------------------------------------------|----------------------------------------------|
| Default                                                                                  | `lingering_close on;`                        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                       |

Controls how Angie closes client connections.

| `on`     | Angie will [wait for](#lingering-timeout) and [process](#lingering-time) additional data from a client before fully closing a connection, but only if heuristics suggests that a client may be sending more data.   |
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `always` | Angie will always wait for and process additional client data.                                                                                                                                                      |
| `off`    | Angie will not wait for more data and will close the connection immediately. This behavior breaks the protocol and should not be used under normal circumstances.                                                   |

To control closing of HTTP/2 connections, the directive must be specified at the [server](#server) level.

<a id="index-37"></a>

<a id="lingering-time"></a>

### lingering_time

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `lingering_time` time;   |
|------------------------------------------------------------------------------------------|--------------------------|
| Default                                                                                  | `lingering_time 30s;`    |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location   |

When [lingering_close](#lingering-close) is in effect, this directive specifies the maximum time during which Angie will process (read and ignore) additional data coming from a client. After that, the connection will be closed, even if there will be more data.

<a id="index-38"></a>

<a id="lingering-timeout"></a>

### lingering_timeout

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `lingering_timeout` time;   |
|------------------------------------------------------------------------------------------|-----------------------------|
| Default                                                                                  | `lingering_timeout 5s;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location      |

When [lingering_close](#lingering-close) is in effect, this directive specifies the maximum
waiting time for more client data to arrive. If data are not received during
this time, the connection is closed. Otherwise, the data are read and ignored,
and Angie starts waiting for more data again. The "wait-read-ignore" cycle is
repeated, but no longer than specified by the [lingering_time](#lingering-time) directive.

During graceful shutdown, client keepalive connections are closed only when
they have been idle for at least the time specified in `lingering_timeout`.

#### NOTE
In nginx, the analogous directive is called [keepalive_min_timeout](https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_min_timeout).

<a id="index-39"></a>

<a id="listen"></a>

### listen

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `listen` address[:port] [`default_server`] [`ssl`] [http2 | `quic`] [`proxy_protocol`] [`setfib=`number] [`fastopen=`number] [`backlog=`number] [`rcvbuf=`size] [`sndbuf=`size] [`accept_filter=`filter] [`deferred`] [`bind`] [`ipv6only=``on` | `off`] [`reuseport`] [`so_keepalive=`on|off|[`keepidle`]:[`keepintvl`]:[`keepcnt`]];<br/><br/>`listen` port [`default_server`] [`ssl`] [http2 | `quic`] [`proxy_protocol`] [`setfib=`number] [`fastopen=`number] [`backlog=`number] [`rcvbuf=`size] [`sndbuf=`size] [`accept_filter=`filter] [`deferred`] [`bind`] [`ipv6only=``on` | `off`] [`reuseport`] [`so_keepalive=`on|off|[`keepidle`]:[`keepintvl`]:[`keepcnt`]];<br/><br/>`listen` unix:path [`default_server`] [`ssl`] [http2 | `quic`] [`proxy_protocol`] [`backlog=`number] [`rcvbuf=`size] [`sndbuf=`size] [`accept_filter=`filter] [`deferred`] [`bind`] [`so_keepalive=`on|off|[`keepidle`]:[`keepintvl`]:[`keepcnt`]];   |
|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Default                                                                                  | `listen *:80` | `*:8000;`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

Sets the address and port for the listening socket, or the path for a UNIX domain
socket on which the server will accept requests. An address may also be a
hostname, for example:

```nginx
listen 127.0.0.1:8000;
listen 127.0.0.1;
listen 8000;
listen *:8000;
listen localhost:8000;
```

IPv6 addresses are specified in square brackets:

```nginx
listen [::]:8000;
listen [::1];
```

UNIX domain sockets are specified with the `unix:` prefix:

```nginx
listen unix:/var/run/angie.sock;
```

Both address and port, or only address or only port, can be specified.
When some parts are omitted, the following rules apply:

- If only the address is given, port 80 is used.
- If only the port is given,
  Angie listens on all available IPv4 (and IPv6, if enabled) interfaces.
  The first `server` block for that port
  becomes the default server for requests with an unmatched `Host` header.
- If the directive is omitted entirely, Angie uses `*:80`
  when running with superuser privileges or `*:8000` otherwise.

| `default_server`   | The server with this parameter specified<br/>will be the default server for the given address:port pair<br/>(together they form a *listening socket*).<br/><br/>If there are no directives with the `default_server` parameter,<br/>the default server for the listening socket<br/>will be the first server in the configuration that serves this socket.                                           |
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ssl`              | indicates that all connections accepted on this listening socket should work in SSL mode. This allows for a more [compact configuration](https://en.angie.software//angie/docs/configuration/ssl.md#compact-server) for the server that handles both HTTP and HTTPS requests.                                                                                                                        |
| `http2`            | configures the port to accept HTTP/2 connections. Normally, for this to work the `ssl` parameter should be specified as well, but Angie can also be configured to accept HTTP/2 connections without SSL.<br/><br/>#### Deprecated<br/>Deprecated since version 1.2.0.<br/><br/>Use the [http2](https://en.angie.software//angie/docs/configuration/modules/http/http_v2.md#http2) directive instead. |
| `quic`             | configures the port to accept QUIC connections.<br/>To use this option,<br/>Angie must have the [HTTP3 module](https://en.angie.software//angie/docs/configuration/modules/http/http_v3.md#http-v3)<br/>enabled and configured.<br/>With `quic` set,<br/>you can also specify `reuseport`<br/>so multiple worker processes can be used.                                                              |
| `proxy_protocol`   | indicates that all connections accepted on this listening socket should use the PROXY protocol.                                                                                                                                                                                                                                                                                                      |

The `listen` directive can also specify several additional parameters specific to socket-related system calls. These parameters can be specified in any `listen` directive, but only once for a given listening socket:

| `setfib=`number                                                    | sets the routing table, FIB (the `SO_SETFIB` option) for the listening socket. This currently works only on FreeBSD.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
|--------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `fastopen=`number                                                  | enables "TCP Fast Open" for the listening socket and limits the maximum length for the queue of connections that have not yet completed the three-way handshake.<br/><br/>#### WARNING<br/>Do not enable "TCP Fast Open" unless the server can handle receiving the same SYN packet with data more than once.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `backlog=`number                                                   | sets the `backlog` parameter in the `listen()` call that<br/>limits the maximum length for the queue of pending connections. By<br/>default, backlog is set to -1 on FreeBSD, DragonFly BSD, and macOS, and<br/>to 511 on other platforms.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `rcvbuf=`size                                                      | sets the receive buffer size (the `SO_RCVBUF` option) for the<br/>listening socket.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `sndbuf=`size                                                      | sets the send buffer size (the `SO_SNDBUF` option) for the<br/>listening socket.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `accept_filter=`filter                                             | sets the name of accept filter (the `SO_ACCEPTFILTER` option) for<br/>the listening socket that filters incoming connections before passing<br/>them to `accept()`. This works only on FreeBSD and NetBSD 5.0+.<br/>Possible values are `dataready` and `httpready`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `deferred`                                                         | instructs to use a deferred `accept()` (the<br/>`TCP_DEFER_ACCEPT` socket option) on Linux.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `bind`                                                             | instructs to make a separate `bind()` call for a given address:port<br/>pair. This is useful because if there are several `listen`<br/>directives with the same port but different addresses, and one of the<br/>`listen` directives listens on all addresses for the given<br/>`port` (`*:port`), Angie will `bind()` only to<br/>`*:port`. It should be noted that the `getsockname()` system<br/>call will be made in this case to determine the address that accepted the<br/>connection. If the `setfib`, `fastopen`, `backlog`,<br/>`rcvbuf`, `sndbuf`, `accept_filter`, `deferred`,<br/>`ipv6only`, `reuseport` or `so_keepalive` parameters<br/>are used then for a given `address:port` pair a separate `bind()`<br/>call will always be made. |
| `ipv6only=on` | `off`                                              | determines (via the `IPV6_V6ONLY` socket option)<br/>whether an IPv6 socket listening on a wildcard address [::] will accept<br/>only IPv6 connections or both IPv6 and IPv4 connections. This parameter<br/>is turned on by default. It can only be set once on start.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `reuseport`                                                        | instructs to create an individual listening socket for<br/>each worker process (using the `SO_REUSEPORT` socket option on<br/>Linux 3.9+ and DragonFly BSD, or `SO_REUSEPORT_LB` on FreeBSD 12+),<br/>allowing a kernel to distribute incoming connections between worker<br/>processes. This currently works only on Linux 3.9+, DragonFly BSD, and<br/>FreeBSD 12+.<br/><br/>#### WARNING<br/>Inappropriate use of the `reuseport` parameter<br/>may have security implications.                                                                                                                                                                                                                                                                      |
| `multipath`                                                        | enables accepting connections via [Multipath TCP](https://en.wikipedia.org/wiki/Multipath_TCP) (MPTCP),<br/>supported in the Linux kernel since version 5.6.<br/>This parameter is **incompatible** with `quic`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `so_keepalive=on` | `off` | [`keepidle`]:[`keepintvl`]:[`keepcnt`] | configures the "TCP keepalive" behavior for the listening socket.<br/><br/>| `''`   | if this parameter is omitted then the operating system's settings will be in effect for the socket   |<br/>|--------|------------------------------------------------------------------------------------------------------|<br/>| `on`   | the `SO_KEEPALIVE` option is turned on for the socket                                                |<br/>| `off`  | the `SO_KEEPALIVE` option is turned off for the socket                                               |                                                                                                                                                                                          |

Some operating systems support setting of TCP keepalive parameters on a
per-socket basis using the `TCP_KEEPIDLE`, `TCP_KEEPINTVL`, and
`TCP_KEEPCNT` socket options. On such systems (currently, Linux, NetBSD,
Dragonfly, FreeBSD, and macOS), they can be configured using the
`keepidle`, `keepintvl`, and `keepcnt` parameters. One or two
parameters may be omitted, in which case the system default setting for the
corresponding socket option will be in effect. For example,

```nginx
so_keepalive=30m::10
```

will set the idle timeout (`TCP_KEEPIDLE`) to 30 minutes, leave the probe interval (`TCP_KEEPINTVL`) at its system default, and set the probes count (`TCP_KEEPCNT`) to 10 probes.

Example:

```nginx
listen 127.0.0.1 default_server accept_filter=dataready backlog=1024;
```

<a id="index-40"></a>

<a id="location"></a>

### location

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `location` ([ = | ~ | ~\* | ^~ ] uri | `@name`)+ { ... }   |
|------------------------------------------------------------------------------------------|------------------------------------------------------------|
| Default                                                                                  | —                                                          |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | server, location                                           |

Sets the configuration depending on whether the request URI matches
any of the matching expressions.

The matching is performed against a normalized URI, after decoding the text
encoded in the "%XX" form, resolving references to relative path components "."
and "..", and possible [compression](#merge-slashes) of two or more
adjacent slashes into a single slash.

A `location` can either be defined by a prefix string, or by a regular
expression.

Regular expressions are specified with the preceding modifier:

| `~*`   | Case-insensitive matching   |
|--------|-----------------------------|
| `~`    | Case-sensitive matching     |

To find a location that matches a request, Angie first checks the
locations defined with prefix strings (prefix locations). Among them, the location
with the longest matching prefix is selected and remembered.

#### NOTE
For case-insensitive operating systems such as macOS, prefix string matching
is case insensitive.
However, matching is limited to single-byte locales.

Then regular expressions are checked in the order of their appearance in the
configuration file. The search stops after the first match, and the corresponding
configuration is used. If no match with a regular expression is found, then the
configuration of the prefix location remembered earlier is used.

With some exceptions mentioned below,
`location` blocks can be nested.

Regular expressions can create capture groups
that can later be used with other directives.

If the longest matching prefix location has the `^~` modifier,
then regular expressions are not checked.

Also, using the `=` modifier, it is possible to define an exact match of URI and
location. If an exact match is found, the search terminates. For example, if a
`/` request happens frequently, defining `location =/` will speed up
the processing of these requests, as the search terminates after the first comparison.
Such a location cannot contain nested locations, as it defines an exact match.

Example:

```nginx
location =/ {
   #configuration A
}

location / {
   #configuration B
}

location /documents/ {
   #configuration C
}

location ^~/images/ {
   #configuration D
}

location ~*\.(gif|jpg|jpeg)$ {
   #configuration E
}
```

- A `/` request will match configuration A,
- an `/index.html` request will match configuration B,
- a `/documents/document.html` request will match configuration C,
- an `/images/1.gif` request will match configuration D,
- and a `/documents/1.jpg` request will match configuration E.

<a id="location-redirect"></a>

#### NOTE
If a prefix `location` ends with a slash character and
[auto_redirect](#auto-redirect) is enabled, the following occurs:
When a request arrives with a URI that has no trailing slash
but otherwise matches the prefix exactly, a permanent redirect
with code 301 is returned, pointing to the requested URI with a slash appended.

With an exact URI-matching location, redirection isn't applied:

```nginx
location /user/ {
  proxy_pass http://user.example.com;
}

location =/user {
  proxy_pass http://login.example.com;
}
```

<a id="named-location"></a>

The `@` prefix defines a *named* `location`. Such locations aren't used for regular request processing,
but instead are only intended for request redirection.
They cannot be nested and cannot contain nested locations.

<a id="combined-locations"></a>

#### Combined locations

Several `location` contexts that define identical configuration blocks
can be compacted by listing all their matching expressions in a single
`location` with a single configuration block.
That's called a *combined* `location`.

Suppose that configurations A, D, and E from the previous example
define identical configurations; you can combine them into one `location`:

```nginx
location =/
         ^~/images/
         ~*\.(gif|jpg|jpeg)$ {
   # general configuration
}
```

A named `location` can also be a part of the combination:

```nginx
location =/
         @named_combined {
   #...
}
```

#### WARNING
A combined `location` can't have a space between the matching expression
modifier and the expression itself.
Proper form: `location ~*/match(ing|es|er)$  *...*`.

#### NOTE
Currently, a combined `location` cannot **immediately** contain
`proxy_pass` directives with URI set, nor `api` or `alias`.
However, these directives can be used by locations nested
inside a combined location.

<a id="index-41"></a>

<a id="log-not-found"></a>

### log_not_found

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `log_not_found` `on` | `off`;   |
|------------------------------------------------------------------------------------------|---------------------------------|
| Default                                                                                  | `log_not_found on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location          |

Enables or disables logging of errors about not found files into [error_log](https://en.angie.software//angie/docs/configuration/modules/core.md#error-log).

<a id="index-42"></a>

<a id="log-subrequest"></a>

### log_subrequest

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `log_subrequest` `on` | `off`;   |
|------------------------------------------------------------------------------------------|----------------------------------|
| Default                                                                                  | `log_subrequest off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location           |

Enables or disables logging of subrequests into [access_log](https://en.angie.software//angie/docs/configuration/modules/http/http_log.md#access-log).

<a id="index-43"></a>

<a id="max-headers"></a>

### max_headers

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `max_headers` number;   |
|------------------------------------------------------------------------------------------|-------------------------|
| Default                                                                                  | `max_headers 1000;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server            |

Sets the maximum number of client request header fields allowed.
If this limit is exceeded, a `400 (Bad Request)` error is returned.

When this directive is set at the [server](#server) level,
the value from the default server may be applied.
For more information, refer to the [Virtual server selection](https://en.angie.software//angie/docs/configuration/processing.md#virtual-server-selection) section.

<a id="index-44"></a>

<a id="max-ranges"></a>

### max_ranges

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `max_ranges` number;   |
|------------------------------------------------------------------------------------------|------------------------|
| Default                                                                                  | —                      |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location |

Limits the maximum allowed number of ranges in byte-range requests. Requests that exceed the limit are processed as if there were no byte ranges specified. By default, the number of ranges is not limited.

| `0`   | disables the byte-range support completely   |
|-------|----------------------------------------------|

<a id="index-45"></a>

<a id="merge-slashes"></a>

### merge_slashes

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `merge_slashes` `on` | `off`;   |
|------------------------------------------------------------------------------------------|---------------------------------|
| Default                                                                                  | `merge_slashes on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server                    |

Enables or disables compression of two or more adjacent slashes in a URI into a single slash.

Note that compression is essential for the correct matching of prefix string and regular expression locations. Without it, the `//scripts/one.php` request would not match

```nginx
location /scripts/ { }
```

and might be processed as a static file. So it gets converted to `/scripts/one.php`.

Turning the compression off can become necessary if a URI contains base64-encoded names, since base64 uses the "/" character internally. However, for security considerations, it is better to avoid turning the compression off.

If the directive is specified on the [server](#server) level, the value from the default server can be used.

<a id="index-46"></a>

<a id="msie-padding"></a>

### msie_padding

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `msie_padding` `on` | `off`;   |
|------------------------------------------------------------------------------------------|--------------------------------|
| Default                                                                                  | `msie_padding on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location         |

Enables or disables adding comments to responses for MSIE clients with status greater than 400 to increase the response size to 512 bytes.

<a id="index-47"></a>

<a id="msie-refresh"></a>

### msie_refresh

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `msie_refresh` `on` | `off`;   |
|------------------------------------------------------------------------------------------|--------------------------------|
| Default                                                                                  | `msie_refresh off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location         |

Enables or disables issuing refreshes instead of redirects for MSIE clients.

<a id="index-48"></a>

<a id="open-file-cache"></a>

### open_file_cache

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `open_file_cache` `off`;<br/><br/>`open_file_cache` `max=`N [`inactive=`time];   |
|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| Default                                                                                  | `open_file_cache off;`                                                           |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                                                           |

Configures a cache that can store:

* open file descriptors, their sizes and modification times;
* information on existence of directories;
* file lookup errors, such as "file not found", "no read permission", and so on.

Caching of errors should be enabled separately by the [open_file_cache_errors](#open-file-cache-errors) directive.

| `max`      | sets the maximum number of elements in the cache; on cache overflow the least recently used (LRU) elements are removed                        |
|------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `inactive` | defines a time after which an element is removed from the cache if it has not been accessed during this time;<br/><br/>by default, 60 seconds |
| `off`      | disables the cache                                                                                                                            |

Example:

```nginx
open_file_cache          max=1000 inactive=20s;
open_file_cache_valid    30s;
open_file_cache_min_uses 2;
open_file_cache_errors   on;
```

<a id="index-49"></a>

<a id="open-file-cache-errors"></a>

### open_file_cache_errors

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `open_file_cache_errors` `on` | `off`;   |
|------------------------------------------------------------------------------------------|------------------------------------------|
| Default                                                                                  | `open_file_cache_errors off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                   |

Enables or disables caching of file lookup errors by [open_file_cache](#open-file-cache).

<a id="index-50"></a>

<a id="open-file-cache-min-uses"></a>

### open_file_cache_min_uses

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `open_file_cache_min_uses` number;   |
|------------------------------------------------------------------------------------------|--------------------------------------|
| Default                                                                                  | `open_file_cache_min_uses 1;`        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location               |

Sets the minimum number of file accesses during the period configured by the `inactive` parameter of the [open_file_cache](#open-file-cache) directive, required for a file descriptor to remain open in the cache.

<a id="index-51"></a>

<a id="open-file-cache-valid"></a>

### open_file_cache_valid

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `open_file_cache_valid` time;   |
|------------------------------------------------------------------------------------------|---------------------------------|
| Default                                                                                  | `open_file_cache_valid 60s;`    |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location          |

Sets a time after which [open_file_cache](#open-file-cache) elements should be validated.

<a id="index-52"></a>

<a id="output-buffers"></a>

### output_buffers

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `output_buffers` number size;   |
|------------------------------------------------------------------------------------------|---------------------------------|
| Default                                                                                  | `output_buffers 2 32k;`         |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location          |

Sets the number and size of the buffers used for reading a response from a disk.

<a id="index-53"></a>

<a id="port-in-redirect"></a>

### port_in_redirect

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `port_in_redirect` `on` | `off`;   |
|------------------------------------------------------------------------------------------|------------------------------------|
| Default                                                                                  | `port_in_redirect on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location             |

Enables or disables specifying the port in [absolute](#absolute-redirect) redirects issued by Angie.

The use of the primary server name in redirects is controlled by the [server_name_in_redirect](#server-name-in-redirect) directive.

<a id="index-54"></a>

<a id="postpone-output"></a>

### postpone_output

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `postpone_output` size;   |
|------------------------------------------------------------------------------------------|---------------------------|
| Default                                                                                  | `postpone_output 1460;`   |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location    |

If possible, the transmission of client data will be postponed until Angie has at least the specified number of bytes to send.

| `0`   | disables postponing data transmission   |
|-------|-----------------------------------------|

<a id="index-55"></a>

<a id="read-ahead"></a>

### read_ahead

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `read_ahead` size;     |
|------------------------------------------------------------------------------------------|------------------------|
| Default                                                                                  | `read_ahead 0;`        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location |

Sets the amount of pre-reading for the kernel when working with files.

On Linux, the `posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL)` system call is used, and so the size parameter is ignored.

On FreeBSD, the `fcntl(O_READAHEAD,` size ) system call, supported since FreeBSD 9.0-CURRENT, is used.

<a id="index-56"></a>

<a id="recursive-error-pages"></a>

### recursive_error_pages

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `recursive_error_pages` `on` | `off`;   |
|------------------------------------------------------------------------------------------|-----------------------------------------|
| Default                                                                                  | `recursive_error_pages off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                  |

Enables or disables doing several redirects using the [error_page](#error-page) directive. The number of such redirects is [limited](#internal).

<a id="index-57"></a>

<a id="request-pool-size"></a>

### request_pool_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `request_pool_size` size;   |
|------------------------------------------------------------------------------------------|-----------------------------|
| Default                                                                                  | `request_pool_size 4k;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server                |

Allows accurate tuning of per-request memory allocations. This directive has minimal impact on performance and should not generally be used.

<a id="index-58"></a>

<a id="reset-timedout-connection"></a>

### reset_timedout_connection

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `reset_timedout_connection` `on` | `off`;   |
|------------------------------------------------------------------------------------------|---------------------------------------------|
| Default                                                                                  | `reset_timedout_connection off;`            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                      |

Enables or disables resetting timed-out connections and connections closed with the non-standard code 444. The reset is performed as follows. Before closing a socket, the `SO_LINGER` option is set for it with a timeout value of 0. When the socket is closed, TCP RST is sent to the client, and all memory associated with this socket is released. This helps avoid keeping an already closed socket in the FIN_WAIT1 state with filled buffers for a long time.

#### NOTE
keep-alive connections are closed normally when they time out.

<a id="index-59"></a>

<a id="resolver"></a>

### resolver

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `resolver` address ... [`valid=`time] [`ipv4=``on` | `off`] [`ipv6=``on` | `off`] [`status_zone=`zone];   |
|------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| Default                                                                                  | —                                                                                                         |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location, upstream                                                                          |

Configures name servers used to resolve names of upstream servers into addresses, for example:

```nginx
resolver 127.0.0.53 [::1]:5353;
```

The address can be specified as a domain name or IP address, with an optional port. If port is not specified, the port 53 is used. Name servers are queried in a round-robin fashion.

#### NOTE
Prefer a local trusted resolver such as `127.0.0.53` (systemd-resolved)
over a public one (e.g. `8.8.8.8`). Public resolvers expose DNS queries
to third parties and increase susceptibility to cache-poisoning attacks.

#### NOTE
The directive value is inherited by nested blocks
and can be overridden in them if necessary.
Within a single block, the directive may only be specified once.
If it is repeated, the last definition takes effect.

By default, Angie caches answers using the TTL value of a response. If the `resolver` directive is not specified and no dynamic DNS queries are performed (for example, when using fixed names in [Proxy](https://en.angie.software//angie/docs/configuration/modules/http/http_proxy.md#http-proxy) without variables), specifying a resolver is not required: names will be resolved at startup using the system resolver. The optional `valid` parameter allows overriding this:

| `valid`   | *optional* parameter allows overriding the response cache validity period   |
|-----------|-----------------------------------------------------------------------------|
```nginx
resolver 127.0.0.53 [::1]:5353 valid=30s;
```

By default, Angie will look up both IPv4 and IPv6 addresses while resolving.

| `ipv4=off`   | disables looking up of IPv4 addresses   |
|--------------|-----------------------------------------|
| `ipv6=off`   | disables looking up of IPv6 addresses   |

<a id="resolver-status"></a>

| `status_zone`   | *optional* parameter;<br/>enables the collection of DNS server request and response metrics<br/>([/status/resolvers/<zone>](https://en.angie.software//angie/docs/configuration/modules/http/http_api.md#api-status-resolvers))<br/>in the specified zone   |
|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

<a id="index-60"></a>

<a id="resolver-timeout"></a>

### resolver_timeout

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `resolver_timeout` time;         |
|------------------------------------------------------------------------------------------|----------------------------------|
| Default                                                                                  | `resolver_timeout 30s;`          |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location, upstream |

Sets a timeout for name resolution, for example:

```nginx
```

resolver_timeout 5s;

<a id="index-61"></a>

<a id="error-log-user-tag"></a>

### error_log_user_tag

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `error_log_user_tag` value;          |
|------------------------------------------------------------------------------------------|--------------------------------------|
| Default                                                                                  | —                                    |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location, limit_except |

Adds a request-specific tag to error log records. The value is a [complex value](https://en.angie.software//angie/docs/configuration/configfile.md#syntax)
and can use variables. The directive can be specified multiple times to add multiple tags.
Tags can be matched with `filter=tag:` in [error_log](https://en.angie.software//angie/docs/configuration/modules/core.md#error-log).

<a id="index-62"></a>

<a id="root"></a>

### root

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `root` path;                           |
|------------------------------------------------------------------------------------------|----------------------------------------|
| Default                                                                                  | `root html;`                           |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location, if in location |

Sets the root directory for requests. For example, with the following configuration

```nginx
location /i/ {
  root /data/w3;
}
```

The `/data/w3/i/top.gif` file will be sent in response to the `/i/top.gif` request.

The path value can contain variables, except [$document_root](#v-document-root) and [$realpath_root](#v-realpath-root).

A path to the file is constructed by merely adding a URI to the value of the root directive. If a URI has to be modified, the [alias](#alias) directive should be used.

<a id="index-63"></a>

<a id="satisfy"></a>

### satisfy

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `satisfy` `all` | `any`;   |
|------------------------------------------------------------------------------------------|----------------------------|
| Default                                                                                  | `satisfy all;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location     |

Allows access if all (`all`) or at least one (`any`) of the [Access](https://en.angie.software//angie/docs/configuration/modules/http/http_access.md#http-access), [Auth Basic](https://en.angie.software//angie/docs/configuration/modules/http/http_auth_basic.md#http-auth-basic), or [Auth Request](https://en.angie.software//angie/docs/configuration/modules/http/http_auth_request.md#http-auth-request) modules allow access.

```nginx
location / {
  satisfy any;

  allow 192.168.1.0/32;
  deny  all;

  auth_basic           "closed site";
  auth_basic_user_file conf/htpasswd;
}
```

<a id="index-64"></a>

<a id="send-lowat"></a>

### send_lowat

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `send_lowat` size;     |
|------------------------------------------------------------------------------------------|------------------------|
| Default                                                                                  | `send_lowat 0;`        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location |

If the directive is set to a non-zero value, Angie will try to minimize the number of send operations on client sockets by using either the `NOTE_LOWAT` flag of the [kqueue](https://en.angie.software//angie/docs/configuration/processing.md#kqueue) method or the `SO_SNDLOWAT` socket option. In both cases the specified size is used.

<a id="index-65"></a>

<a id="send-timeout"></a>

### send_timeout

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `send_timeout` time;   |
|------------------------------------------------------------------------------------------|------------------------|
| Default                                                                                  | `send_timeout 60s;`    |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location |

Sets a timeout for transmitting a response to the client. The timeout is set only between two successive write operations, not for the transmission of the whole response. If the client does not receive anything within this time, the connection is closed.

<a id="index-66"></a>

<a id="sendfile"></a>

### sendfile

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `sendfile` `on` | `off`;               |
|------------------------------------------------------------------------------------------|----------------------------------------|
| Default                                                                                  | `sendfile off;`                        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location, if in location |

Enables or disables the use of `sendfile()`.

[aio](#aio) can be used to pre-load data for `sendfile()`:

```nginx
location /video/ {
  sendfile       on;
  tcp_nopush     on;
  aio            on;
}
```

In this configuration, `sendfile()` is called with the `SF_NODISKIO` flag which causes it not to block on disk I/O, but, instead, report back that the data are not in memory. Angie then initiates an asynchronous data load by reading one byte. On the first read, the FreeBSD kernel loads the first 128K bytes of a file into memory, although next reads will only load data in 16K chunks. This can be changed using the [read_ahead](#read-ahead) directive.

<a id="index-67"></a>

<a id="sendfile-max-chunk"></a>

### sendfile_max_chunk

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `sendfile_max_chunk` size;   |
|------------------------------------------------------------------------------------------|------------------------------|
| Default                                                                                  | `sendfile_max_chunk 2m;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location       |

Limits the amount of data that can be transferred in a single `sendfile()` call. Without the limit, one fast connection may seize the worker process entirely.

<a id="index-68"></a>

<a id="server"></a>

### server

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `server` { ... }   |
|------------------------------------------------------------------------------------------|--------------------|
| Default                                                                                  | —                  |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http               |

Sets configuration for a virtual server. There is no clear separation between IP-based (based on the IP address) and name-based (based on the "Host" request header field) virtual servers. Instead, the [listen](#listen) directives describe all addresses and ports that should accept connections for the server, and the [server_name](#server-name) directive lists all server names.

Example configurations are provided in the [How Angie processes a request](https://en.angie.software//angie/docs/configuration/processing.md#request-processing) document.

<a id="index-69"></a>

<a id="server-name"></a>

### server_name

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `server_name` name ...;   |
|------------------------------------------------------------------------------------------|---------------------------|
| Default                                                                                  | `server_name ""`;         |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | server                    |

Sets names of a virtual server, for example:

```nginx
server {
  server_name example.com www.example.com;
}
```

The first name becomes the primary server name.

Server names can include an asterisk ("\*") replacing the first or last part of a name:

```nginx
server {
  server_name example.com *.example.com www.example.*;
}
```

Such names are called wildcard names.

The first two of the names mentioned above can be combined in one:

```nginx
server {
  server_name .example.com;
}
```

It is also possible to use regular expressions in server names, preceding the name with a tilde ("~"):

```nginx
server {
  server_name ~^www\d+\.example\.com$ www.example.com;
}
```

Regular expressions can contain captures that can later be used in other directives:

```nginx
server {
  server_name ~^(www\.)?(.+)$;

  location / {
     root /sites/$2;
  }
}

server {
  server_name _;

  location / {
     root /sites/default;
  }
}
```

Named captures in regular expressions create variables
that can later be used in other directives:

```nginx
server {
  server_name ~^(www\.)?(?<domain>.+)$;

  location / {
     root /sites/$domain;
  }
}

server {
  server_name _;

  location / {
     root /sites/default;
  }
}
```

#### NOTE
If the directive's parameter is set to [$hostname](#v-hostname),
the machine name is used.

An empty server name can also be specified:

```nginx
server {
    server_name www.example.com "";
}
```

When searching for a virtual server by name,
if the name matches more than one of the specified variants
(for example, both a wildcard name and regular expression match),
the first matching variant will be chosen, in the following order of priority:

- exact name;
- longest wildcard name starting with an asterisk, e.g. `*.example.com`;
- longest wildcard name ending with an asterisk, e.g. `mail.*`;
- first matching regular expression (in order of appearance in the configuration file),
  including an empty name.

#### WARNING
To use `server_name` with TLS,
TLS connection termination is required.
This directive matches against the `Host` in the HTTP request,
so the handshake must be completed and the connection decrypted.

<a id="index-70"></a>

<a id="server-name-in-redirect"></a>

### server_name_in_redirect

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `server_name_in_redirect` `on` | `off`;   |
|------------------------------------------------------------------------------------------|-------------------------------------------|
| Default                                                                                  | `server_name_in_redirect off`;            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                    |

Enables or disables the use of the primary server name, specified by the [server_name](#server-name) directive, in [absolute](#absolute-redirect) redirects issued by Angie.

| `on`   | the primary server name set by the [server_name](#server-name) directive is used                                           |
|--------|----------------------------------------------------------------------------------------------------------------------------|
| `off`  | the name from the "Host" request header field is used. If this field is not present, the IP address of the server is used. |

The use of the port in redirects is controlled by the [port_in_redirect](#port-in-redirect) directive.

<a id="index-71"></a>

<a id="server-names-hash-bucket-size"></a>

### server_names_hash_bucket_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `server_names_hash_bucket_size` size;              |
|------------------------------------------------------------------------------------------|----------------------------------------------------|
| Default                                                                                  | `server_names_hash_bucket_size 32` | `64` | `128;` |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http                                               |

Sets the bucket size for the server names hash tables. The default value depends on the size of the processor's cache line. The details of setting up hash tables are provided in a [separate document](https://en.angie.software//angie/docs/configuration/configfile.md#configure-hashes).

<a id="index-72"></a>

<a id="server-names-hash-max-size"></a>

### server_names_hash_max_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `server_names_hash_max_size` size;   |
|------------------------------------------------------------------------------------------|--------------------------------------|
| Default                                                                                  | `server_names_hash_max_size 512`;    |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http                                 |

Sets the maximum size of the server names hash tables. The details of setting up hash tables are provided in a [separate document](https://en.angie.software//angie/docs/configuration/configfile.md#configure-hashes).

<a id="index-73"></a>

<a id="server-tokens"></a>

### server_tokens

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `server_tokens` `on` | `off` | `build` | string;   |
|------------------------------------------------------------------------------------------|----------------------------------------------------|
| Default                                                                                  | `server_tokens on;`                                |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                             |

Enables or disables emitting Angie version
on error pages and in the `Server` response header field.
The `build` parameter enables emitting the build name,
set by the respective [configure](https://en.angie.software//angie/docs/installation/sourcebuild.md#configure) parameter,
along with the version.

In Angie PRO, if the directive sets a string, which may also contain variables,
the error pages and the `Server` response header field
will use the string's variable-interpolated value
instead of server name, version, and build name.
An empty string disables emitting the `Server` field.

<a id="index-74"></a>

<a id="status-zone"></a>

### status_zone

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `status_zone` `off` | zone | key `zone=`zone[:number];   |
|------------------------------------------------------------------------------------------|----------------------------------------------------------|
| Default                                                                                  | —                                                        |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | server, location, if in location                         |

Allocates a shared memory zone for collecting
[/status/http/location_zones/<zone>](https://en.angie.software//angie/docs/configuration/modules/http/http_api.md#api-status-http-location-zones) and [/status/http/server_zones/<zone>](https://en.angie.software//angie/docs/configuration/modules/http/http_api.md#api-status-http-server-zones) metrics.

Several `server` contexts
can share the same zone for data collection;
the special value `off`
disables data collection in nested `location` blocks.

The syntax with a single zone value
combines all metrics for the current context into one shared memory zone:

```nginx
server {

    listen 80;
    server_name *.example.com;

    status_zone single;
    # ...
}
```

The alternative syntax allows setting the following parameters:

| key               | A string with variables, whose value determines the grouping of requests in<br/>the zone. All requests producing identical values after substitution<br/>are grouped together. If substitution yields an empty value,<br/>metrics aren't updated.   |
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| zone              | The name of the shared memory zone.                                                                                                                                                                                                                 |
| number (optional) | The maximum number of separate groups for collecting metrics.<br/>If new key values would exceed this limit, they are grouped under `zone` instead.<br/><br/>The default value is 1.                                                                |

In the following example,
all requests sharing the same `$host` value
are grouped into the `host_zone`.
Metrics are tracked separately for each unique `$host`
until there are 10 metric groups.
Once this limit is reached,
any additional `$host` values are included under the `host_zone`:

```nginx
server {

    listen 80;
    server_name *.example.com;

    status_zone $host zone=host_zone:10;

    location / {

        proxy_pass http://example.com;
    }
}
```

The resulting metrics are thus split between individual hosts in the API output.

<a id="index-75"></a>

<a id="subrequest-output-buffer-size"></a>

### subrequest_output_buffer_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `subrequest_output_buffer_size` size;      |
|------------------------------------------------------------------------------------------|--------------------------------------------|
| Default                                                                                  | `subrequest_output_buffer_size 4k` | `8k;` |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                     |

Sets the size of the buffer used for storing the response body of a subrequest.
By default, the buffer size is equal to one memory page. This is either
`4K` or `8K`, depending on a platform. It can be made smaller,
however.

#### NOTE
The directive is applicable only for subrequests with response bodies saved into memory. For example, such subrequests are created by [SSI](https://en.angie.software//angie/docs/configuration/modules/http/http_ssi.md#ssi-include-set).

<a id="index-76"></a>

<a id="tcp-nodelay"></a>

### tcp_nodelay

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `tcp_nodelay` `on` | `off`;   |
|------------------------------------------------------------------------------------------|-------------------------------|
| Default                                                                                  | `tcp_nodelay on;`             |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location        |

Enables or disables the use of the `TCP_NODELAY` option. The option is enabled when a connection is transitioned into the keep-alive state. Additionally, it is enabled on SSL connections, for unbuffered proxying, and for [WebSocket proxying](https://en.angie.software//angie/docs/configuration/processing.md#websocket-proxy).

<a id="index-77"></a>

<a id="tcp-nopush"></a>

### tcp_nopush

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `tcp_nopush` `on` | `off`;   |
|------------------------------------------------------------------------------------------|------------------------------|
| Default                                                                                  | `tcp_nopush off`;            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location       |

Enables or disables the use of the `TCP_NOPUSH` socket option on FreeBSD or the `TCP_CORK` socket option on Linux. The options are enabled only when [sendfile](#sendfile) is used. Enabling the option allows

* sending the response header and the beginning of a file in one packet, on Linux and FreeBSD 4.\*;
* sending a file in full packets.

<a id="index-78"></a>

<a id="try-files"></a>

### try_files

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `try_files` file ... uri;<br/><br/>`try_files` file ... =code;   |
|------------------------------------------------------------------------------------------|------------------------------------------------------------------|
| Default                                                                                  | —                                                                |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | server, location                                                 |

Checks the existence of files in the specified order and uses the first found file for request processing; the processing is performed in the current location's context. The path to a file is constructed from the file parameter according to the [root](#root) and [alias](#alias) directives. It is possible to check directory's existence by specifying a slash at the end of a name, e.g. `$uri/`. If none of the files were found, an internal redirect to the uri specified in the last parameter is made.

For example:

```nginx
location /images/ {
  try_files $uri /images/default.gif;
}

location = /images/default.gif {
  expires 30s;
}
```

The last parameter can be a URI for an internal redirect,
a reference to a named `location` (e.g., `@drupal`),
or a response code in the form `=code` (e.g., `=404`):

```nginx
location / {
  try_files $uri $uri/index.html $uri.html =404;
}
```

It should be noted that excessive use of the `try_files` directive
increases the number of system calls,
which can negatively impact performance.

Thus, `try_files` should not be used to replicate behavior
that is effectively the default behavior, for example:

```nginx
location /bad_pattern {

      # try_files $uri $uri/ =404;  # not recommended!
}
```

Also, `try_files` should not be used
solely for redirecting when a file is absent.
The reason is that the `try_files` directive has two peculiarities:

- First, it checks the existence of each file,
  which increases system load.
- Second, any file opening errors (e.g., `too many open files`,
  permission errors) are also treated as file absence and trigger a fallback
  to the backup handler, which can mask 5xx errors with successful responses
  and lead to incorrect caching.

Thus, in practice, the following problematic construction can be encountered:

```nginx
location / {
   try_files $uri $uri/ @drupal;  # not recommended!
}
```

The problem here is that the only purpose is redirection.
Using `try_files` leads to the disadvantages listed above,
but provides no benefits,
since checking for file existence is not needed.
The correct solution is to use the [error_page](#error-page) directive,
which does not have these disadvantages:

```nginx
error_page 404 = @drupal;
log_not_found off;
```

In contrast, in the following example:

```nginx
location ~ \.php$ {
  try_files $uri @drupal;

  fastcgi_pass ...;

  fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;

#  ...
}
```

The `try_files` directive checks for the existence of the PHP file
before passing the request to the FastCGI server configured in the same block;
here the use of `try_files` is justified.

### Example of use when proxying to Mongrel:

```nginx
location / {
  try_files /system/maintenance.html
           $uri $uri/index.html $uri.html
           @mongrel;
}

location @mongrel {
  proxy_pass http://mongrel;
}
```

### Example of use with Drupal/FastCGI:

```nginx
location / {
  error_page 404 = @drupal;
}

location ~ \.php$ {
  try_files $uri @drupal;

  fastcgi_pass ...;

  fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;
  fastcgi_param SCRIPT_NAME     $fastcgi_script_name;
  fastcgi_param QUERY_STRING    $args;

#  ... other fastcgi_param
}

location @drupal {
  fastcgi_pass ...;

  fastcgi_param SCRIPT_FILENAME /path/to/index.php;
  fastcgi_param SCRIPT_NAME     /index.php;
  fastcgi_param QUERY_STRING    q=$uri&$args;

#  ... other fastcgi_param
}
```

### Example of use with Wordpress and Joomla:

```nginx
location / {
  error_page 404 = @wordpress;
}

location ~ \.php$ {
  try_files $uri @wordpress;

  fastcgi_pass ...;

  fastcgi_param SCRIPT_FILENAME /path/to$fastcgi_script_name;
#  ... other fastcgi_param
}

location @wordpress {
  fastcgi_pass ...;

  fastcgi_param SCRIPT_FILENAME /path/to/index.php;
#  ... other fastcgi_param
}
```

<a id="index-79"></a>

<a id="types"></a>

### types

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `types` { ... }                                            |
|------------------------------------------------------------------------------------------|------------------------------------------------------------|
| Default                                                                                  | `types  *text/html html; image/gif gif; image/jpeg jpg;* ` |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location                                     |

Maps file name extensions to MIME types of responses. Extensions are case-insensitive. Several extensions can be mapped to one type, for example:

```nginx
types {
  application/octet-stream bin exe dll;
  application/octet-stream deb;
  application/octet-stream dmg;
}
```

A sufficiently complete mapping table is distributed with Angie and is located in the `conf/mime.types` file.

To make a particular `location` return the "application/octet-stream" MIME type for all responses, the following configuration can be used:

```nginx
location /download/ {
  types        { }
  default_type application/octet-stream;
}
```

<a id="index-80"></a>

<a id="types-hash-bucket-size"></a>

### types_hash_bucket_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `types_hash_bucket_size` size;   |
|------------------------------------------------------------------------------------------|----------------------------------|
| Default                                                                                  | `types_hash_bucket_size 64;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location           |

Sets the bucket size for the types hash tables. The details of setting up hash tables are discussed [separately](https://en.angie.software//angie/docs/configuration/configfile.md#configure-hashes).

<a id="index-81"></a>

<a id="types-hash-max-size"></a>

### types_hash_max_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `types_hash_max_size` size;   |
|------------------------------------------------------------------------------------------|-------------------------------|
| Default                                                                                  | `types_hash_max_size 1024;`   |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server, location        |

Sets the maximum size of the types hash tables. The details of setting up hash tables are discussed [separately](https://en.angie.software//angie/docs/configuration/configfile.md#configure-hashes).

<a id="index-82"></a>

<a id="underscores-in-headers"></a>

### underscores_in_headers

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `underscores_in_headers` `on` | `off`;   |
|------------------------------------------------------------------------------------------|------------------------------------------|
| Default                                                                                  | `underscores_in_headers off`;            |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http, server                             |

Enables or disables the use of underscores in client request header fields. When the use of underscores is disabled, request header fields whose names contain underscores are marked as invalid and are subject to the [ignore_invalid_headers](#ignore-invalid-headers) directive.

If the directive is specified at the [server](#server) level, the value from the default server can be used.

<a id="index-83"></a>

<a id="variables-hash-bucket-size"></a>

### variables_hash_bucket_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `variables_hash_bucket_size` size;   |
|------------------------------------------------------------------------------------------|--------------------------------------|
| Default                                                                                  | `variables_hash_bucket_size 64;`     |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http                                 |

Sets the bucket size for the variables hash table. The details of setting up hash tables are discussed [separately](https://en.angie.software//angie/docs/configuration/configfile.md#configure-hashes).

<a id="index-84"></a>

<a id="variables-hash-max-size"></a>

### variables_hash_max_size

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `variables_hash_max_size` size;   |
|------------------------------------------------------------------------------------------|-----------------------------------|
| Default                                                                                  | `variables_hash_max_size 2048;`   |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | http                              |

Sets the maximum size of the variables hash table. The details of setting up hash tables are discussed [separately](https://en.angie.software//angie/docs/configuration/configfile.md#configure-hashes).

<a id="http-core-variables"></a>

## Built-in Variables

The `http_core` module supports built-in variables with names matching the
Apache Server variables. First of all, these are variables representing client
request header fields, such as `$http_user_agent`, `$http_cookie`,
and so on. Also, there are other variables:

<a id="v-angie-version"></a>

### `$angie_version`

Angie version

<a id="v-arg"></a>

### `$arg_<name>`

argument name in the request line

<a id="v-args"></a>

### `$args`

arguments in the request line

<a id="v-binary-remote-addr"></a>

### `$binary_remote_addr`

client address in a binary form, value's length is always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses

<a id="v-body-bytes-sent"></a>

### `$body_bytes_sent`

number of bytes sent to the client, not counting the response header; this variable is compatible with the "%B" parameter of the `mod_log_config` Apache module

<a id="v-bytes-sent"></a>

### `$bytes_sent`

number of bytes sent to a client

<a id="v-connection"></a>

### `$connection`

connection serial number

<a id="v-connection-requests"></a>

### `$connection_requests`

current number of requests made through a connection

<a id="v-connection-time"></a>

### `$connection_time`

connection time in seconds with a milliseconds resolution

<a id="v-content-length"></a>

### `$content_length`

`Content-Length` request header field

<a id="v-content-type"></a>

### `$content_type`

`Content-Type` request header field

<a id="v-cookie"></a>

### `$cookie_<name>`

cookie with the specified name

<a id="v-document-root"></a>

### `$document_root`

[root](#root) or [alias](#alias) directive's value for the current request

<a id="v-document-uri"></a>

### `$document_uri`

same as [$uri](#v-uri)

<a id="v-host"></a>

### `$host`

in this order of precedence: host name from the request line, or host name from the "Host" request header field, or the server name matching a request

<a id="v-hostname"></a>

### `$hostname`

host name

<a id="v-http"></a>

### `$http_<name>`

arbitrary request header field; the last part of the variable name corresponds to the field name converted to lower case with dashes replaced by underscores

<a id="v-https"></a>

### `$https`

`on` if connection operates in SSL mode, or an empty string otherwise

<a id="v-is-args"></a>

### `$is_args`

`?` if a request line has arguments, or an empty string otherwise

<a id="v-is-request-port"></a>

### `$is_request_port`

`:` if the [$request_port](#v-request-port) value is non-empty, or an empty string otherwise

<a id="v-limit-rate"></a>

### `$limit_rate`

setting this variable enables response rate limiting; see [limit_rate](#limit-rate)

<a id="v-msec"></a>

### `$msec`

current time in seconds with the milliseconds resolution

<a id="v-nginx-version"></a>

### `$nginx_version`

nginx version

<a id="v-pid"></a>

### `$pid`

PID of the worker process

<a id="v-pipe"></a>

### `$pipe`

`p` if request was pipelined, `.` otherwise

<a id="v-proxy-protocol-addr"></a>

### `$proxy_protocol_addr`

client address from the PROXY protocol header

The PROXY protocol must be previously enabled by setting the `proxy_protocol` parameter in the [listen](#listen) directive.

<a id="v-proxy-protocol-port"></a>

### `$proxy_protocol_port`

client port from the PROXY protocol header

The PROXY protocol must be previously enabled by setting the `proxy_protocol` parameter in the [listen](#listen) directive.

<a id="v-proxy-protocol-server-addr"></a>

### `$proxy_protocol_server_addr`

server address from the PROXY protocol header

The PROXY protocol must be previously enabled by setting the `proxy_protocol` parameter in the [listen](#listen) directive.

<a id="v-proxy-protocol-server-port"></a>

### `$proxy_protocol_server_port`

server port from the PROXY protocol header

The PROXY protocol must be previously enabled by setting the `proxy_protocol` parameter in the [listen](#listen) directive.

<a id="v-proxy-protocol-tlv"></a>

### `$proxy_protocol_tlv_<name>`

TLV from the PROXY protocol header. The name can be a TLV type name or its numeric value. In the latter case, the value is hexadecimal and should be prefixed with `0x`:

```none
$proxy_protocol_tlv_alpn
$proxy_protocol_tlv_0x01
```

SSL TLVs can also be accessed by TLV type name or its numeric value, both prefixed by `ssl_`:

```none
$proxy_protocol_tlv_ssl_version
$proxy_protocol_tlv_ssl_0x21
```

The following TLV type names are supported:

* `alpn (0x01)` - upper layer protocol used over the connection
* `authority (0x02)` - host name value passed by the client
* `unique_id (0x05)` - unique connection id
* `netns (0x30)` - name of the namespace
* `ssl (0x20)` - binary SSL TLV structure

The following SSL TLV type names are supported:

* `ssl_version (0x21)` - SSL version used in client connection
* `ssl_cn (0x22)` - SSL certificate Common Name
* `ssl_cipher (0x23)` - name of the used cipher
* `ssl_sig_alg (0x24)` - algorithm used to sign the certificate
* `ssl_key_alg (0x25)` - public-key algorithm

Also, the following special SSL TLV type name is supported:

* `ssl_verify` - client SSL certificate verification result: `0` if the client presented a certificate and it was successfully verified, non-zero otherwise

The PROXY protocol must be previously enabled by setting the `proxy_protocol` parameter in the [listen](#listen) directive.

<a id="v-query-string"></a>

### `$query_string`

same as [$args](#v-args)

<a id="v-realpath-root"></a>

### `$realpath_root`

an absolute pathname corresponding to the [root](#root) or [alias](#alias) directive's value for the current request, with all symbolic links resolved to real paths

<a id="v-remote-addr"></a>

### `$remote_addr`

client address

<a id="v-remote-port"></a>

### `$remote_port`

client port

<a id="v-remote-user"></a>

### `$remote_user`

user name supplied with the Basic authentication

<a id="v-request"></a>

### `$request`

full original request line

<a id="v-request-body"></a>

### `$request_body`

request body

The variable's value is *made available* in locations processed by the [proxy_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_proxy.md#proxy-pass), [fastcgi_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_fastcgi.md#fastcgi-pass), [uwsgi_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_uwsgi.md#uwsgi-pass), and [scgi_pass](https://en.angie.software//angie/docs/configuration/modules/http/http_scgi.md#scgi-pass) directives when the request body was read to a [memory buffer](#client-body-buffer-size).

<a id="v-request-body-file"></a>

### `$request_body_file`

name of a temporary file with the request body

At the end of processing, the file needs to be removed. To always write the request body to a file, enable [client_body_in_file_only](#client-body-in-file-only). When passing the name of a temporary file in a proxied request or in a request to a FastCGI/uwsgi/SCGI server, the passing of the request body itself should be disabled with the [proxy_pass_request_body off](https://en.angie.software//angie/docs/configuration/modules/http/http_proxy.md#proxy-pass-request-body), [fastcgi_pass_request_body off](https://en.angie.software//angie/docs/configuration/modules/http/http_fastcgi.md#fastcgi-pass-request-body), [uwsgi_pass_request_body off](https://en.angie.software//angie/docs/configuration/modules/http/http_uwsgi.md#uwsgi-pass-request-body), or [scgi_pass_request_body off](https://en.angie.software//angie/docs/configuration/modules/http/http_scgi.md#scgi-pass-request-body) directives, respectively.

<a id="v-request-completion"></a>

### `$request_completion`

`OK` if a request has completed, or an empty string otherwise

<a id="v-request-filename"></a>

### `$request_filename`

file path for the current request, based on the [root](#root) or [alias](#alias) directives, and the request URI

<a id="v-request-id"></a>

### `$request_id`

unique request identifier generated from 16 random bytes, in hexadecimal

<a id="v-request-length"></a>

### `$request_length`

request length (including request line, header, and request body)

<a id="v-request-method"></a>

### `$request_method`

request method, usually `GET` or `POST`

<a id="v-request-port"></a>

### `$request_port`

in this order of precedence: port number from the authority component of the request URI, or port number from the "Host" request header field

<a id="v-request-time"></a>

### `$request_time`

request processing time in seconds with a milliseconds resolution; time elapsed since the first bytes were read from the client

<a id="v-request-uri"></a>

### `$request_uri`

full original request URI (with arguments), never modified during request processing; see [$uri](#v-uri) for the current (potentially rewritten) URI

<a id="v-scheme"></a>

### `$scheme`

request scheme, "http" or "https"

<a id="v-sent-body"></a>

### `$sent_body`

response body of a subrequest or external request when it is stored in memory;
otherwise an empty string

<a id="v-sent-http"></a>

### `$sent_http_<name>`

arbitrary response header field; the last part of the variable name corresponds to the field name converted to lower case with dashes replaced by underscores

<a id="v-sent-trailer"></a>

### `$sent_trailer_<name>`

arbitrary field sent at the end of the response; the last part of the variable name corresponds to the field name converted to lower case with dashes replaced by underscores

<a id="v-server-addr"></a>

### `$server_addr`

address of the server which accepted a request

Computing a value of this variable usually requires one system call. To avoid a system call, the [listen](#listen) directives must specify addresses and use the `bind` parameter.

<a id="v-server-name"></a>

### `$server_name`

name of the server which accepted a request

<a id="v-server-port"></a>

### `$server_port`

port of the server which accepted a request

<a id="v-server-protocol"></a>

### `$server_protocol`

request protocol, usually "HTTP/1.0", "HTTP/1.1", or "HTTP/2.0"

<a id="v-status"></a>

### `$status`

response status

<a id="v-time-iso8601"></a>

### `$time_iso8601`

local time in the ISO 8601 standard format

<a id="v-time-local"></a>

### `$time_local`

local time in the Common Log Format

<a id="v-tcpinfo"></a>

### `$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space`

information about the client TCP connection; available on systems that support the `TCP_INFO` socket option

<a id="v-uri"></a>

### `$uri`

current URI in request, [normalized](#location)

The value of `$uri` may change during request processing, e.g. when rewriting with [rewrite](https://en.angie.software//angie/docs/configuration/modules/http/http_rewrite.md#id4), when doing internal redirects, or when using index files.
