标签:
当使用nginx的limit_req模块,limit_req_zone有两个变量,就会报错。
【nginx的limit_req模块只能有一个变量,而Tenginx可以支持多个,具体的可以查看官网的模块介绍,很坑,换了tenginx即可】
http://www.ithov.com/linux/114606.shtml
http://nginx.org/en/docs/http/ngx_http_limit_req_module.html
nginx报错:
[root@www ~]# /root/nginx_reload
nginx: [emerg] invalid number of arguments in "limit_req_zone" directive in /usr/local/nginx/conf/nginx.conf:52
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
limit_req需求:
同一IP来源同一URI 15r/m
同一IP来源 30r/m
http段:
geo $white_ip {
ranges;
default 0;
127.0.0.1-127.0.0.255 1;
192.168.168.1-192.168.168.254 1;
}
limit_req_zone $binary_remote_addr $uri zone=reqzone:20m rate=15r/m;
limit_req_zone $binary_remote_addr zone=req_ip:10m rate=30r/m;
limit_req_whitelist geo_var_name=white_ip geo_var_value=1;
server段:
location ~ ^/test/.*\.html {
limit_req zone=reqzone burst=5 nodelay;
limit_req zone=req_ip burst=5 nodelay;
proxy_pass http://WEB_APP;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
标签:
原文地址:http://my.oschina.net/fufangchun/blog/521247