nginx:split_clients内部的变量扩展不起作用?

时间:2015-05-04 15:53:29

标签: nginx

我有以下配置:

map $host $variant_a {
  default 'a';
}
map $host $variant_b {
  default 'b';
}
map $host $variant_c {
  default 'c';
}
map $host $variant_d {
  default 'd';
}
map $host $variant_default {
  default 'default';
}
# a/b testing
split_clients "abtest${remote_addr}${http_user_agent}${date_gmt}" $variant_chosen {
    20%     $variant_a;
    20%     $variant_b;
    20%     $variant_c;
    20%     $variant_d;
    20%     $variant_default;
}

server {
    # defaults test independent
    listen 80;
    server_name _;
    root /home/vagrant/www;
    index index.html;
    error_page 404 = 404.html;
    error_page 403 = 404.html;

    location / {
        echo a=$variant_a,variant_chosen=$variant_chosen
    }

}

当我对服务器执行查询时:

curl -i http://192.168.33.10/

我可以看到'split_clients'内的变量从未扩展过。

示例输出:

vagrant@precise32:~/www$ curl -i http://192.168.33.10/
HTTP/1.1 200 OK
Server: nginx/1.1.19
Date: Mon, 04 May 2015 15:46:17 GMT
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Connection: keep-alive

a=a,variant_chosen=$variant_default

任何人都知道为什么变量没有扩展?

任何帮助高度赞赏

欢呼声 烫发

0 个答案:

没有答案