Nginx 中使用 cookie 灰度或分流
前言
Nginx.conf
$COOKIE_gray
gray 为 cookie key
true,false 为命中逻辑,可为正则
http {
include mime.types;
default_type application/octet-stream;
map $COOKIE_gray $group {
true apache001;
false apache002;
default apache002;
}
upstream apache001 {
server 192.168.1.101:3001 weight=1 max_fails=1 fail_timeout=30s;
}
upstream apache002 {
server 192.168.1.102:8000 weight=1 max_fails=1 fail_timeout=30s;
}
sendfile on;
keepalive_timeout 65;
server {
listen 3000;
server_name localhost;
location / {
proxy_pass http://$group;
}
}
include servers/*;
}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 kshao-blog-前端知识记录!
评论