~/info 限流失败
~info 和~/info 都能匹配到值,$limit_key_pc_page_info 的值输出 page_info
为什么加/符号会影响限流?$limit_key_pc_page_info 里面有值
1 、nginx 配置
# 变量-URI
map $uri $limit_key_pc_page_info {
~/info "page_info";
#~info "page_info";
default "";
}
limit_req_zone $limit_key_pc_page_info zone=limit_zone_pc_page_info:10m rate=1r/s;
server {
listen 80;
server_name www.dunhanson.com;
charset utf-8;
location / {
# 限流
limit_req zone=limit_zone_pc_page_info nodelay;
proxy_pass http://www_dunhanson_com;
}
}
server {
listen 80;
server_name test.dunhanson.com;
charset utf-8;
location / {
default_type text/plain;
return 200 "$uri $limit_key_pc_page_info";
}
}
2 、测试效果
curl http://test.dunhanson.com/info-558860051.html
输出: /info-558860051.html page_info