› 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 · 5020 views
    This topic created in 4195 days ago, the information mentioned may be changed or developed.

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

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

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

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

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