nginx做白名单以及灰度流量控制
2015-11-12 13:38
701 查看
首先是nginx.conf
gated_launch.conf
调用方访问以下接口,即可知道该请求是否在白名单以及灰度名单中。
127.0.0.1:80/?uid=1
注意端口号后面的/是必须的,不然拿不到header。
response只包含header,如下:
HTTP/1.1 200 OK
Server: nginx/1.9.3
Date: Thu, 12 Nov 2015 03:25:56 GMT
Content-Type: text/html
Content-Length: 0
Last-Modified: Thu, 12 Nov 2015 02:11:36 GMT
Connection: keep-alive
ETag: "5643f558-0"
gated_launch: true
white_list: false
Accept-Ranges: bytes
gated_launch 表示是否在灰度名单。
white_list 表示是否在白名单。
user root root; worker_processes 4; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; include gated_launch.conf; server { listen 80; server_name localhost; location / { add_header gated_launch $gated_launch; add_header white_list $white_list; root html; } } }
gated_launch.conf
split_clients "${arg_uid}" $gated_launch { 50% true; 50% false; } map $arg_uid $white_list { 20 true; 50 true; 60 true; 5678 true; default false; }
调用方访问以下接口,即可知道该请求是否在白名单以及灰度名单中。
127.0.0.1:80/?uid=1
注意端口号后面的/是必须的,不然拿不到header。
response只包含header,如下:
HTTP/1.1 200 OK
Server: nginx/1.9.3
Date: Thu, 12 Nov 2015 03:25:56 GMT
Content-Type: text/html
Content-Length: 0
Last-Modified: Thu, 12 Nov 2015 02:11:36 GMT
Connection: keep-alive
ETag: "5643f558-0"
gated_launch: true
white_list: false
Accept-Ranges: bytes
gated_launch 表示是否在灰度名单。
white_list 表示是否在白名单。
相关文章推荐
- nginx相关知识
- phalconphp nginx 配置
- (总结)Nginx配置文件nginx.conf中文详解
- Nginx+PHP On windows
- Nginx配置thinkPHP 支持phpinfo和rewrite
- Nginx配置文件详细说明
- Mogilefs分布式文件系统-Keepalived+Nginx双主模型实现图片分布式存储、访问
- Nginx安装
- 运行和控制Nginx
- nginx 支持thinkphp pathinfo最简单的方法
- 适用于Ubuntu的最新版Nginx源整理
- Nginx 中last和break 及 permanent 和 redirect 的爱恨情仇
- nginx进程模型
- NGINX
- ubuntu安装nodejs, nginx
- linux 中php以及nginx的重启命令
- NGINX扩展
- Nginx 安装配置入门
- 初学 nginx 之location(一)
- Nginx 源码完全剖析 nginx 自旋锁 ngx_spinlock