Stream upstream directives

server (stream)

upstream context; defines a peer and optional weight/failure settings.

Formal Syntax & Structure

nginx syntaxnginx
server address [parameters];

Parameters & Attributes

NameTypeDescription
addresshost:port | unix:pathPeer endpoint; DNS name may represent multiple peers.
weightweight=numberRelative selection weight.
max_connsmax_conns=numberActive upstream connection limit; zero unlimited, per worker without zone.
max_failsmax_fails=numberConnection failures counted within fail_timeout; zero disables failure accounting.
fail_timeoutfail_timeout=durationFailure window and temporary exclusion duration.
rolebackup | downBackup peer or administratively unavailable peer; backup incompatible with some balancing algorithms.
resolveliteral resolveDynamic DNS requires shared zone and resolver; OSS since 1.27.3.
serviceservice=nameSRV lookup with resolve and hostname without port; OSS since 1.27.3.
commercial_optionsslow_start=duration | other supported commercial optionsCheck exact edition before using recovery and commercial state options.

Working Example

Example Snippetnginx
server 127.0.0.1:19112 weight=2;
Nginx Reference