This module is not distributed with the Nginx source. Installation instructions are Installation below.
The upstream_hash module provides simple upstream load distribution by hashing a configurable variable (e.g., the request URI, incoming HTTP headers, or some combination). Example usage:
Here, Nginx will choose server1 or server2 by hashing the request URI ($request_uri).
syntax hash $variable
Enables upstream hashing of $variable.
When present, the "server" directives cannot take any arguments ("weight", "max_fails", etc.).
syntax hash_again number
Number of times to rehash the value and choose a different server if the backend connection fails. Increase this number to provide high availability.
This module is not distributed with the Nginx source. You can download the request_hash module here: File:Nginx upstream hash-0.3.1.tar.gz
After extracting, you will need to patch the latest Nginx source (0.7.62 as of this writing). Run patch like this:
cd nginx-0.7.62 # or whatever patch -p0 < /path/to/upstream/hash/directory/nginx.patch
Then add the following option to your Nginx ./configure command:
Then "make" and "make install" as usual.
The hash algorithm
As of 0.3, the hash algorithm and the failover algorithm use a CRC-32 computation compatible with PECL Memcache.
- . * 0.3.1: Updated patch to work with latest Nginx sources
- . * 0.3: Feature: PECL Memcache compatibility. Change: Removed "hash_method" directive.
Send bug reports to Evan Miller .