Nginx教程

nginx-AB测试

本文主要是介绍nginx-AB测试,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

来源ip:

server {
listen 80;
server_name officecloud.com;
access_log officecloud.com/logs main;
ip_list 192.168.254.4,192.168.254.170

set $group default;
if ($remote_addr in iplist) {
set $group ACluster;
}
location / {
proxy_pass http://$group;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
index index.html index.htm;
}
}
优缺点:

1、配置简单,原资源平台的灰度升级就是根据IP名单来划分设计升级的

2、外部计算机很多都是非固定IP,这个适合在公司内网实现,比如只是配置公司内网的IP。

$.Cookies策略

server {
listen 80;
server_name officecloud.com;
access_log officecloud.com/logs main;
ip_list 192.168.254.4,192.168.254.170

set $group default;
if ($http_cookie ~* "version=V1.0"){
set default;
}
if ($http_cookie ~* "version=V1.1"){
set $group ACluster;
}

location / {
proxy_pass http://$group;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
index index.html index.htm;
}
}
优缺点:

1、配置简单,根据Nginx的 $COOKIE_version 属性来判断

2、相对稳定,对需要开放名单的用户,在Cookie头部加入特定的版本即可,应用只要少许的开发量

3、首次访问静态页面可能不会产生cookie

这篇关于nginx-AB测试的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!