V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
telu
V2EX  ›  程序员

反向代理服务器限流请教

  •  
  •   telu · May 21, 2016 · 2297 views
    This topic created in 3634 days ago, the information mentioned may be changed or developed.

    我经过反向代理将网站的推送服务转移到另一个服务器,现在还想对这块内容进行限流,

    在新服务器设置限流时使用 MAP 之后,限制结果还是只能针对内网的服务器,而不是针对真实IP

    反向代理配置

    
    proxy_set_header X-Forwarded-For $remote_addr;
    #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    #proxy_set_header X-Real-IP  $remote_addr;
    #proxy_set_header Host $host;
    
    

    限流配置

    
    map $http_x_forwarded_for  $clientRealIp {
        "" $remote_addr;
        ~^(?P<firstaddr>[0-9\.]+),?.*$ $firstAddr;
    }
    #limit_req_zone $binary_remote_addr zone=allips:10m rate=2r/m;
    limit_req_zone $clientRealIp zone=allips:10m rate=2r/m;
    limit_req zone=allips burst=5 nodelay;
    
    

    请问一下要怎样才能对真实 IP 限流呢。

    设置参考了 http://zhangge.net/4879.html

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   879 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:51 · PVG 06:51 · LAX 15:51 · JFK 18:51
    ♥ Do have faith in what you're doing.