V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
holinhot
V2EX  ›  NGINX

nginx 如何限制某人地区的不法访问

  •  
  •   holinhot · May 16, 2015 · 4642 views
    This topic created in 4008 days ago, the information mentioned may be changed or developed.

    比如限制只有广东省内的用户才能打开
    其他地区一律拒绝连接

    17 replies    2015-05-16 20:48:58 +08:00
    shiniv
        1
    shiniv  
       May 16, 2015
    用 GeoIP
    Septembers
        2
    Septembers  
       May 16, 2015
    see http://nginx.org/en/docs/http/ngx_http_geo_module.html

    无论用什么IP库都存在误杀概率
    lshero
        3
    lshero  
       May 16, 2015
    --with-http_geoip_module

    但是geoip对二级运营商地域判断不是很准
    holinhot
        4
    holinhot  
    OP
       May 16, 2015
    @lshero 到省就可以了
    holinhot
        5
    holinhot  
    OP
       May 16, 2015
    @shiniv
    @Septembers
    geoip对国内省份好像不太准
    lshero
        6
    lshero  
       May 16, 2015
    @holinhot 是的,但是是最快捷的办法了,比如北京有一家做企业专线的叫做光环新网geoip基本都识别为河北廊坊
    hiboshi
        7
    hiboshi  
       May 16, 2015
    dns 分省解析可以么
    holinhot
        8
    holinhot  
    OP
       May 16, 2015
    @hiboshi 我是要从服务器上严格限制,dns那太自由了 改个hosts就能访问了
    holinhot
        9
    holinhot  
    OP
       May 16, 2015
    @lshero 我想要是只允许某个省的电信用户访问就好了
    jsthon
        10
    jsthon  
       May 16, 2015 via Android
    @holinhot 我想到了为什么不直接从DNS入手呢?禁止访问的地区/线路直接解析到127.0.0.1。
    jsthon
        11
    jsthon  
       May 16, 2015 via Android
    @jsthon 抱歉,楼上已经说明了。那这样的话,搜索引擎收录也会影响喔,这样要突破封锁就只能用代理之类了吧。
    lianyue
        12
    lianyue  
       May 16, 2015
    http://ip.taobao.com 准确率蛮高的 有api
    holinhot
        13
    holinhot  
    OP
       May 16, 2015
    @jsthon 要的就是这个效果啊
    holinhot
        14
    holinhot  
    OP
       May 16, 2015
    @lianyue nginx有模块?
    holinhot
        15
    holinhot  
    OP
       May 16, 2015
    @shiniv
    @Septembers
    @hiboshi
    @lshero
    @hiboshi
    @jsthon
    @lianyue

    能在iptables上限制吗 区域外的ip直接拦截
    lincanbin
        16
    lincanbin  
       May 16, 2015
    @holinhot iptables当然可以,但是能精确到运营商的IP库不多,而且收费的居多。
    aalska
        17
    aalska  
       May 16, 2015
    。。。。。。。。ipip不是有api 获取ip还可以 在chromium可以支持API获取大致经纬度,时区么
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1270 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 83ms · UTC 23:43 · PVG 07:43 · LAX 16:43 · JFK 19:43
    ♥ Do have faith in what you're doing.