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

NameTypeDescription
addressaddress:port | port | unix:pathChoose a listening endpoint; prefer loopback for local practice.
transportudp | omittedUDP since 1.9.13; omission selects TCP.
sslliteral sslEnable TLS on the listener; requires stream SSL support.
proxy_protocolliteral proxy_protocolRequire incoming PROXY metadata from a controlled peer; not an outbound setting.
socket_optionsreuseport | default_server | backlog=number | rcvbuf=size | sndbuf=size | bind | ipv6only=on/off | other documented optionsOptional 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;
Nginx Reference