<!-- review: finished -->

<a id="stream-realip"></a>

# RealIP

Allows changing the client address and port to those passed in the PROXY protocol header. The PROXY protocol must be previously enabled by setting the `proxy_protocol` parameter in the [listen](https://en.angie.software//angie/docs/configuration/modules/stream/index.md#s-listen) directive.

When [building from the source code](https://en.angie.software//angie/docs/installation/sourcebuild.md#sourcebuild),
this module isn't built by default;
it should be enabled with the
`‑‑with‑stream_realip_module`
[build option](https://en.angie.software//angie/docs/installation/sourcebuild.md#configure).

In packages and images from [our repos](https://en.angie.software//angie/docs/installation/index.md#install-packages),
the module is included in the build.

<a id="configuration-example-67"></a>

## Configuration Example

```nginx
listen 12345 proxy_protocol;

set_real_ip_from  192.168.1.0/24;
set_real_ip_from  192.168.2.1;
set_real_ip_from  2001:0db8::/32;
```

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

## Directives

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

<a id="s-set-real-ip-from"></a>

### set_real_ip_from

| [Syntax](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)   | `set_real_ip_from` address | CIDR | `unix:`;   |
|------------------------------------------------------------------------------------------|------------------------------------------------|
| Default                                                                                  | —                                              |
| [Context](https://en.angie.software//angie/docs/configuration/configfile.md#configfile)  | stream, server                                 |

Defines trusted addresses that are known to send correct replacement addresses. If the special value `unix:` is specified, all UNIX domain sockets will be trusted.

<a id="built-in-variables-22"></a>

## Built-in Variables

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

### `$realip_remote_addr`

keeps the original client address

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

### `$realip_remote_port`

keeps the original client port
