我正在尝试使用 a/b 测试功能在 azure 的 NGINX 中创建网关。 我设法从网上找到了配置
http {
# Set up a key‑value store to specify the percentage to send to each
# upstream group based on the 'Host' header.
keyval_zone zone=split:64k state=/etc/nginx/state_files/split.json;
keyval $host $split_level zone=split;
upstream appversion1 {
zone appversion1 64k;
server 192.168.50.100;
server 192.168.50.101;
}
upstream appversion2 {
zone appversion2 64k;
server 192.168.50.102;
server 192.168.50.103;
}
split_clients $client_ip $split0 {
* appversion1;
}
split_clients $client_ip $split5 {
5% appversion2;
* appversion1;
}
split_clients $client_ip $split10 {
10% appversion2;
* appversion1;
}
split_clients $client_ip $split25 {
25% appversion2;
* appversion1;
}
split_clients $client_ip $split50 {
50% appversion2;
* appversion1;
}
split_clients $client_ip $split100 {
* appversion2;
}
map $split_level $upstream {
0 $split0;
5 $split5;
10 $split10;
25 $split25;
50 $split50;
100 $split100;
default $split0;
}
server {
listen 80;
# In each 'split_clients' block above, '$client_ip' controls which
# application receives each request. For a production application, we set it
# to '$remote_addr' (the client IP address). But when testing from just one
# client, '$remote_addr' is always the same; to get some randomness, we set
# it to '$request_id' instead.
#set $client_ip $remote_addr; # Production
set $client_ip $request_id; # Testing only
location / {
proxy_pass http://$upstream;
}
}
}
但是当尝试将其上传到 azure split_clients 时不起作用并出现此错误 - /etc/nginx/nginx.conf:21 中的未知指令“*”。
我试图将 * 更改为 100% / 更改位置但没有任何效果。
我用 F5(维护服务的公司)开了一张票,他们在解析配置文件中的 split_clients 时有一个错误。应该在不久的将来修复......