HttpSplitClientsModuleJa

= 概要 =

ngx_http_split_clients_module は、ある条件（IPアドレス、ヘッダ、クッキーなど）に基づいてクライアントを分別するために用いられます.

= 設定例 =

基本的な設定:
http { split_clients "${remote_addr}AAA" $variant { 40.5% ".one"; 59.5% ".two"; }

server { location / { index index${variant}.html; [...]   }

上記の設定例では、パーセンテージを計算するための入力として、変数に文字列を加えたもの ("${remote_addr}AAA") が用いられます. 文字列の値は、 MurmurHash2 (32ビットの整数を生成する) を用いてハッシュ化されます.

この例では:
 * ハッシュ値が 0 から 1739461754 (40.5%) の場合、$variable 変数の値は ".one" となり、"index.one.html" ファイルを読み込もうとする;
 * Hash values from 1739461755 to 4294967295 (59.5%) will set the $variant variable with the value ".two" and will try to load the file "index.two.html";

Sending a query string variable to 51% of clients (to PHP scripts)
http { split_clients "${remote_addr}" $additionalQsVariable { 51% "coolVariable=1"; 49% "";	}

server { location ~ \.php$ { set $args "${query_string}&${additionalQsVariable}"; [...]       }    }

Redirecting 51% of the traffic to another URL
http { split_clients "${remote_addr}" $redirectSite { 51% "1";	   49% "0";	}

server { location / { if ($redirectSite = "1") { return 302 "http://www.website2.com/"; }           [...]        }    }
 * Although on nginx IF is evil, we can use it in this specific case.

Appendix
Instead of ${remote_addr}, one could use ${cookie}, ${args} or any other nginx variable. You may also add a salt (arbitrary string) if you wish.


 * Keep in mind that if you use a variable like ${remote_addr} (user IP), the hash (and percentage) will always be the same as long as the user/client keep the same IP. In other words, the $variant value will always be the same for the same IP.
 * Hashing algorithm is MurmurHash2 since version 1.0.1; Previously CRC32.

= ディレクティブ =

split_clients


= 参照 =


 * Original Documentation
 * Naming convention discussion