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

NameTypeDescription
twoliteral twoSample two peers instead of selecting one.
methodleast_conn | least_time=header | least_time=last_byteOnly with two; default least_conn. Random least_time remains commercial in checked docs.

Working Example

Example Snippetnginx
random two least_conn;
Nginx Reference