HTTP upstream directives

hash directive (HTTP upstream)

HTTP upstream context; since 1.7.2. Selects a peer using a key; consistent mode limits key redistribution on membership changes.

Formal Syntax & Structure

nginx syntaxnginx
hash key [consistent];

Parameters & Attributes

NameTypeDescription
keyexpressionSelect the value used for peer hashing.
consistentliteral consistentUse consistent hashing to reduce remapping after peer changes.

Working Example

Example Snippetnginx
hash $uri consistent;
Nginx Reference