亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

記錄Nginx服務(wù)器的Split Clients模塊配置過程

 更新時(shí)間:2016年01月27日 14:29:28   作者:Deidara  
這篇文章主要介紹了Nginx服務(wù)器的Split Clients模塊的配置過程記錄,ngx-http-split-clients模塊用于切分客戶端連接,需要的朋友可以參考下

ngx-http-split-clients模塊基于一些特定條件分開客戶端連接,(例如ip地址,請(qǐng)求頭,cookies等)
示例配置:

http {
  split-clients "${remote-addr}AAA" $variant {
    0.5% .one;
    2.0% .two;
    - "";
  }
 
  server {
    location / {
       index index${variant}.html;

可以使用$cookie-…作為來源來分離請(qǐng)求,來源字符串使用CRC32進(jìn)行哈希計(jì)算并且哈希百分比將作為來源的值。
指令

split-clients

語法:split-clients $variable { … }
默認(rèn)值:none
使用字段:http

發(fā)現(xiàn)模塊官網(wǎng)wiki給的上面的示例配置代碼有幾點(diǎn)問題,我編譯安裝后,按照wiki的方法配置nginx.conf 報(bào)錯(cuò)。

我實(shí)際的代碼是:

http {
  split_clients "${remote_addr}AAA" $variant {
    0.5% .one;
    2% .two;
    3% .eric;
    4% .yang;
    50% .thr;
    * "";
  }

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

然后新建幾個(gè)文件

cd /usr/local/nginx/html/

echo "one" >index.one.html
echo "two" >index.two.html
echo "eric" >index.eric.html
echo "thr" >index.thr.html

配置差別:

wiki : split-clients   eric:split_clients
wiki : remote-addr    eric: remote_addr
wiki : - "";      eric: * "";
關(guān)于這些錯(cuò)誤的發(fā)現(xiàn)是因?yàn)?nginx 有 remote_addr 變量 并沒有 remote-addr ·我就順藤摸瓜·
隨后我來講下 Split Clients模塊的一點(diǎn)點(diǎn)知識(shí),我自己時(shí)間測(cè)試出來的~
關(guān)于測(cè)試,我們?cè)?nginx 的錯(cuò)誤日志上 輸出 ${variant} 變量
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
         '$status $body_bytes_sent "$http_referer" '
         '"$http_user_agent" "$http_x_forwarded_for" "$variant"';
以便于我們測(cè)試結(jié)果。
Split Clients 的模塊 模塊 是切割 客戶端IP 然后然后 使用CRC32的 算出一個(gè)值去匹配·
在 俄文網(wǎng)站上 翻譯出這么一段:
該指令創(chuàng)造了A / B分割一變
測(cè)試,例如:
http {
  split_clients "${remote_addr}AAA" $variant {
    0.5% .one;
    2% .two;
    * "";
  }

原來的字符串變量的值是哈希
使用CRC32的。在這個(gè)例子中,當(dāng)
哈希值從0到21474836(0.5%),變量$變種
有值“。之一”。如果哈希值21474837
至107374182(2%) - “。兩個(gè)”。而如果從107374183哈希值
4294967297 - “”。
也就是說,比如 我的IP地址是 192.168.1.29 服務(wù)器IP 為 192.168.1.28
當(dāng)我訪問 nginx 的時(shí)候,nginx 會(huì)切割我的IP地址 匹配到 .1
日志:

復(fù)制代碼 代碼如下:

192.168.1.29 - - [01/Apr/2011:15:39:17 +0800] "GET / HTTP/1.1" 403 571 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)" "-" ".thr"


看到的頁(yè)面是 thr
當(dāng)我修改我的 IP 為 192.168.220.29 服務(wù)器IP 為 192.168.220.28
在看日志:

復(fù)制代碼 代碼如下:

192.168.220.29 - - [01/Apr/2011:15:44:46 +0800] "GET / HTTP/1.1" 403 571 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)" "-" ".two"


看到的頁(yè)面是 two
PS:這樣的畫 nginx 里的$variant 變量 可以給我們帶來各種好處了·判斷來自哪個(gè)IP段的分到哪個(gè)服務(wù)器上~!

您可能感興趣的文章:

相關(guān)文章

最新評(píng)論