• nginx优化限制连接请求limit_req


    限制单个IP的请求数量,减少DDOS攻击,节省服务器资源。

    Syntax:	limit_req zone=name [burst=number] [nodelay | delay=number];
    Default:	—
    Context:	http, server, location
    
    Sets the shared memory zone and the maximum burst size of requests. If the requests rate exceeds the rate configured for a zone, their processing is delayed such that requests are processed at a defined rate. Excessive requests are delayed until their number exceeds the maximum burst size in which case the request is terminated with an error. By default, the maximum burst size is equal to zero. For example, the directives
    

    配置如下:

    http {
        ###限制单个IP请求数量  放开指定ip可以没有限制访问
         geo $allow_ip {        #给ip地址赋予value  区别目标ip和普通ip
            default        0;
            222.173.94.214 1;
            127.0.0.1      1;
        }
        
        map $allow_ip $limit_key {          #给普通ip赋予新变量
           0 $binary_remote_addr;
           1 "";
        }
    
        limit_req_zone $limit_key zone=req_zone:10m rate=100r/s;  #引用这个新变量,设定req——zone的大小 设定请求频率
        server {
           ........
           location {
           ........
              limit_req zone=req_zone burst=5 nodelay;            #引用这个zone   设置缓冲容器 缓冲容器允许5个 总共是105个请求不延迟处理  nodelay不延时处理
              proxy_pass http://c2p;
           }
        }
    }
    
  • 相关阅读:
    1 绪论
    3.4 向量空间及其子空间的的基与维数
    3.3 极大线性无关组以及&向量的秩
    3.2 线性相关与线性无关的向量组
    3.1 n维向量空间及其子空间
    2.6 拉普拉斯定理
    2.5 克拉默法则
    2.4 行列式按行(列)展开
    2.3 行列式的性质
    2.2 n阶行列式的定义
  • 原文地址:https://www.cnblogs.com/yangtao416/p/16046027.html
Copyright © 2020-2023  润新知