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
| Name | Type | Description |
|---|---|---|
| address | host:port | unix:path | Peer endpoint; DNS name may represent multiple peers. |
| weight | weight=number | Relative selection weight. |
| max_conns | max_conns=number | Active upstream connection limit; zero unlimited, per worker without zone. |
| max_fails | max_fails=number | Connection failures counted within fail_timeout; zero disables failure accounting. |
| fail_timeout | fail_timeout=duration | Failure window and temporary exclusion duration. |
| role | backup | down | Backup peer or administratively unavailable peer; backup incompatible with some balancing algorithms. |
| resolve | literal resolve | Dynamic DNS requires shared zone and resolver; OSS since 1.27.3. |
| service | service=name | SRV lookup with resolve and hostname without port; OSS since 1.27.3. |
| commercial_options | slow_start=duration | other supported commercial options | Check exact edition before using recovery and commercial state options. |
Working Example
Example Snippetnginx
server 127.0.0.1:19112 weight=2;