简单的灰度测试,lua或者直接改nginx配置
来源:互联网 发布:linux sort k 编辑:程序博客网 时间:2024/05/21 17:32
配置过程:
1.根据cookies特征值实现
在做的过程中把login的操作给做了过滤。登录过程将cookie中设置了一个新的cookie值 SESSIONID =gray这样在nginx配置中
加入筛选
Root不要配置在最前面而是配置在location中
#过滤login 请求进来会优先判断 请求是不是/ gina-client/login 然后判断是不是 / gina-client/
location /client/login {
proxy_pass http://client_stable_gray;
}
登陆过程加上cookie
location /client/{
set $group "client_stable";
if ( $http_cookie ~* "SESSIONID = gray" ) {
set $group "client_stable_gray";
}
proxy_pass http://$group;
}
筛选root
location / {
set root /data0/project/gina/html/agent;
if ( $http_cookie ~*"SESSIONID = gray" ) {
set root /data0/project/gina/html/agent_gray/magneto/dist/agent;
}
}
2.根据cookie ||||| lua方式
如果单独抽出来写lua脚本
cookies_gray.lua
local uin = ngx.var.cookie_loginuin
--取cookies里的loginuin字段,末尾被2整数的灰度
if uin ~= nil and string.sub(uin,string.len(uin))%2 == 0then
ngx.exec("@gray_env")
else
ngx.exec("@product_env")
end
nginx.conf
...
#http
lua_code_cacheoff;#正式上线记得打开cache
lua_package_path"/usr/local/openresty/lualib/?.lua;;";
lua_shared_dictconfig 1m;
...
#server
location / {
#access_by_lua_file conf/lua/ip_gray.lua;
access_by_lua_file conf/lua/cookies_gray.lua;
}
location@gray_env {
proxy_passhttp://gray_env;
proxy_set_header Host $http_host;
}
location@product_env {
proxy_passhttp://product_env;
proxy_set_header Host $http_host;
}
cal uin = ngx.var.cookie_GINA_gray_SESSIONID
if uin ~= nil and uin == 'gray' then
ngx.say("Gray Environment World")
#ngx.exec("@gray_env")
else
ngx.exec("@product_env")
end
- 简单的灰度测试,lua或者直接改nginx配置
- 利用nginx+lua+memcache实现灰度发布
- 利用nginx+lua+memcache实现灰度发布
- 利用nginx+lua+memcache实现灰度发布
- 简单的nginx配置
- nginx lua redis 测试
- Nginx+upload+lua 简单的文件上传
- nginx负载均衡简单测试配置
- nginx配置lua
- nginx+PHP+Lua配置
- nginx-lua配置
- nginx+lua配置,
- nginx lua 配置
- Nginx+KV db进行AB灰度测试
- 简单测试了一下Lua的速度
- nginx 简单的配置(nginx.conf)
- 简单的nginx fastcgi配置
- 最简单的nginx配置
- 中文分词基础中trie树的实现方式研究
- Docker 在Ubuntu环境的安装教程
- MySql查询表结构
- Android图表库MPAndroidChart(四)水平条行图
- Python中的random模块
- 简单的灰度测试,lua或者直接改nginx配置
- 融云集成头像问题
- 多种方式选择剪切头像
- 学生成绩管理系统
- Apache压力测试工具
- Node简单的模块化小例子
- Linux内核同步机制之(一):原子操作
- 获取请求参数乱码处理——蓝图哈达
- PPT九大提高效率实用技巧分享(要收藏哟!)