HTTP upstream directives
random directive (HTTP upstream)
HTTP upstream context; since 1.15.1. Weighted random selection; two defaults to least_conn. Random least_time methods require commercial support.
Formal Syntax & Structure
nginx syntaxnginx
random [two [method]];Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| two | literal two | Sample two peers instead of selecting one. |
| method | least_conn | least_time=header | least_time=last_byte | Only with two; default least_conn. Random least_time remains commercial in checked docs. |
Working Example
Example Snippetnginx
random two least_conn;