upstream_list

The `upstream_list` directive defines a list of upstream servers for NGINX, enabling load balancing and fault tolerance.

Syntaxupstream_list server1 [server2 ...];
Defaultnone
Contexthttp, server
Arguments2+

Description

The upstream_list directive is part of the NGINX Development Kit (NDK) and allows users to create a list of upstream server configurations directly within the server or http blocks. This directive expects at least two arguments: server definitions specifying the upstream servers. Each server entry can include parameters specifying the server’s address and possibly weights for load balancing. The upstream_list enhances the flexibility in managing upstream server configurations by allowing the use of complex path and complex value syntax, enabling more dynamic handling of backend server definitions.

When this directive is used, NGINX will parse the list of defined upstream servers and create a corresponding configuration object, which can then be used for load balancing requests to those servers. The configuration can also manage how the servers are used, including their connection settings, weights for distribution, and handling of failures. The flexibility provided by the upstream_list plays a crucial role in building scalable and resilient applications by allowing the dynamic adjustment of upstream server characteristics without needing a complete server restart.

Furthermore, the directive can include various complex variables, which allow for more advanced setups, such as dynamic server selection based on specific request attributes or server health checks. This makes upstream_list a powerful tool for developers looking to implement advanced load balancing strategies directly within their NGINX configurations.

Config Example

upstream my_backend {
    upstream_list 192.168.1.1:80 192.168.1.2:80;
}

Be cautious about defining too many upstream servers, as this may impact performance.

Ensure server addresses are reachable; unreachable servers will lead to failed requests.

Properly use weights for load balancing to prevent uneven distribution of requests.

← Back to all directives