0
点赞
收藏
分享

微信扫一扫

nginx集成GeoIP2

程序员漫画编程 2022-04-30 阅读 56
经验分享

安装 GeoIP2 依赖

https://github.com/maxmind/libmaxminddb
tar -zxvf libmaxminddb.tar.gz
cd libmaxminddb-1.3.2
./configure && make && make install
echo /usr/local/lib  >> /etc/ld.so.conf.d/local.conf 
ldconfig

下载IP库

https://www.maxmind.com/en/accounts/562897/geoip/downloads

编译模块

https://github.com/leev/ngx_http_geoip2_module
./configure --prefix=/opt/nginx --add-module=/root/ngx_http_geoip2_module-master

配置

    geoip2 /opt/nginx/GeoLite2-Country.mmdb {
    $geoip_country_code default=- source=$http_x_forwarded_for country iso_code;
        $geoip_country_name country names en;
    }

    geoip2 /opt/nginx/GeoLite2-City.mmdb {
        $geoip_city_name default=- city names en;
    }
举报

相关推荐

0 条评论