GASALA
V2EX  ›  问与答

一个关于 iptables 的问题

  •  
  •   GASALA · Feb 21, 2015 · 2895 views
    This topic created in 4118 days ago, the information mentioned may be changed or developed.
    系统是Ubuntu12.04 64位。
    前端Nginx(80),后端Apache(8080)。

    网站采用wordpress搭建。

    针对按F5就挂的问题,我想使用iptables去限制每个IP的最大连接数,增加了以下规则(来自于网络):

    # limit 80 port IP 20
    -A INPUT -p tcp --dport 80 -m connlimit --connlimit-above 20 -j REJECT

    # Log 60 seconds 20 connect
    -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --update --seconds 60 --hitcount 20 -j LOG --log-prefix "DDOS: " --log-ip-options

    # 60 seconds 20 connect
    -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --update --seconds 60 --hitcount 20 -j REJECT

    # Allow
    -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --set -j ACCEPT


    但这些规则最终并没有生效,长按F5就报数据库连接错误。

    请各位帮忙看看问题出在哪?谢谢。
    2 replies    2015-02-22 02:00:40 +08:00
    ryd994
        1
    ryd994  
       Feb 22, 2015
    http有长连接所以请求频率和连接频率不一定一样。用nginx limit request http://nginx.org/en/docs/http/ngx_http_limit_req_module.html
    oott123
        2
    oott123  
       Feb 22, 2015 via Android
    针对按F5就挂的问题,你应该考虑优化你的数据库或者其它的程序对资源的占用,而不是不让人家按…
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5020 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 93c8b4a0 · 52ms · UTC 09:46 · PVG 17:46 · LAX 02:46 · JFK 05:46
    ♥ Do have faith in what you're doing.