Stream core directives
listen (stream)
server context; no default. Selects socket address, transport and supported options. UDP appeared in 1.9.13.
Formal Syntax & Structure
nginx syntaxnginx
listen address:port [udp] [reuseport] ...;Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| address | address:port | port | unix:path | Choose a listening endpoint; prefer loopback for local practice. |
| transport | udp | omitted | UDP since 1.9.13; omission selects TCP. |
| ssl | literal ssl | Enable TLS on the listener; requires stream SSL support. |
| proxy_protocol | literal proxy_protocol | Require incoming PROXY metadata from a controlled peer; not an outbound setting. |
| socket_options | reuseport | default_server | backlog=number | rcvbuf=size | sndbuf=size | bind | ipv6only=on/off | other documented options | Optional platform- and version-dependent socket settings. default_server since 1.25.5; check compatibility before combining. |
Working Example
Example Snippetnginx
listen 127.0.0.1:19111 udp reuseport;