<!-- review: finished -->

<a id="stream-rdp-preread"></a>

# RDP Preread

When using the RDP protocol, this module allows extracting cookies,
which are used for session identification and management,
before making a load balancing decision.

When [building from the source code](https://en.angie.software//angie/docs/installation/sourcebuild.md#sourcebuild),
the module must be enabled with the
`‑‑with‑stream_rdp_preread_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-66"></a>

## Configuration Example

<a id="binding-to-the-cookie-issuing-server"></a>

### Binding to the Cookie-Issuing Server

This configuration uses the `learn` mode of the [sticky](https://en.angie.software//angie/docs/configuration/modules/stream/stream_upstream.md#s-u-sticky) directive:

```nginx
stream {

    rdp_preread on;

    upstream rdp {

        server 127.0.0.1:3390 sid=a;
        server 127.0.0.1:3391 sid=b;

        sticky learn lookup=$rdp_cookie create=$rdp_cookie zone=sessions:1m;
    }
}
```

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

## Directives

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

<a id="s-rdp-preread"></a>

### rdp_preread

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

Controls extracting information from RDP protocol cookies
during the
[preread stage](https://en.angie.software//angie/docs/configuration/processing.md#stream-sessions).
If the setting is `on`,
the variables listed below will be populated
in the context where it is specified.

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

## Built-in Variables

The semantics of cookie values depend on the RDP protocol version.

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

### `$rdp_cookie`

The entire cookie value.

<a id="id3"></a>

### `$rdp_cookie_<name>`

The value of the cookie field with the specified name.
