V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
herozzm
V2EX  ›  问与答

nginx 如何禁止国外 ip 访问,但是放过国外的 google、bing 爬虫 ip 该如何做?

  •  
  •   herozzm · Mar 16, 2023 · 1266 views
    This topic created in 1148 days ago, the information mentioned may be changed or developed.
    看到用 ngx_http_geoip2 模块来禁止所有国外 ip ,如何再放过 google 、bing 爬虫国外 ip 该如何做?
    4 replies    2024-03-12 22:06:45 +08:00
    Rache1
        1
    Rache1  
       Mar 16, 2023
    之前看到过一种较为灵活的方法, 建一个 Redis Set ,由后端去把需要禁止掉的 IP 丢进去。然后在 nginx 里面调 lua 查 Redis 进行处理。
    herozzm
        2
    herozzm  
    OP
       Mar 16, 2023
    @Rache1 我想到一个策略,就是将爬虫的 ip 全部找到弄成白名单
    Rache1
        3
    Rache1  
       Mar 16, 2023
    @herozzm 也可以,各家都是有公布 IP 段的
    abccccabc
        4
    abccccabc  
       Mar 12, 2024
    https://v2ex.com/t/927189#reply12


    楼主,你看下这贴,有你要的答案。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3154 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 00:24 · PVG 08:24 · LAX 17:24 · JFK 20:24
    ♥ Do have faith in what you're doing.