miniyao
V2EX  ›  问与答

前端实时检测一些异常访问 IP,然后通过 nginx 来阻止这些 ip 访问, blocked_IPs 通过什么方式存储比较好?

  •  
  •   miniyao · Sep 17, 2020 · 1327 views
    This topic created in 2151 days ago, the information mentioned may be changed or developed.
    目前是前端检测到异常访问 IP,直接存数据库,然后在业务层拒绝访问。

    现在想把这个拦截前置到 nginx,就是这个 blocked_IPs 用什么方法给到 nginx 呢?

    一般这个 blocked_IPs 会一周之后释放,不再拦截,因此考虑每天更新一下,能不能不重启 nginx 实现?
    3 replies    2020-09-17 15:45:14 +08:00
    dilu
        1
    dilu  
       Sep 17, 2020
    最主流的肯定 redis 啦 用 lua 还能直接取到 很方便噻
    HAWCat
        2
    HAWCat  
       Sep 17, 2020
    用 fail2ban 吧,设置异常规则,设置封锁时间,...等等,封锁时间到了它会自动放行 IP 访问的。
    airyland
        3
    airyland  
       Sep 17, 2020
    定时写到单独的 block.ip 文件,在 nginx 配置中 include 这个文件。每次写入后 nginx -s reload 。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2769 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 04:21 · PVG 12:21 · LAX 21:21 · JFK 00:21
    ♥ Do have faith in what you're doing.