首页 > 其他 > 详细

Nginx配置GeoIP

时间:2020-12-04 21:31:00      阅读:92      评论:0      收藏:0      [点我收藏+]

GItHub:https://github.com/TravelEngineers/ngx_http_geoip2_module

DB文件下载

先注册用户:https://dev.maxmind.com/geoip/geoip2/geolite2/

进入下载页面:https://www.maxmind.com/en/accounts/455551/geoip/downloads

    log_format main escape=json ‘{"remote_addr":"$remote_addr",‘
        ‘"timestamp":"$time_local",‘
        ‘"country":"$geoip2_data_country_name",‘
        ‘"city":"$geoip2_city_name",‘
        ‘"method":"$request_method",‘
        ‘"request":"$uri",‘
        ‘"requestParam":"$query_string",‘
        ‘"status":"$status",‘
        ‘"referrer":"$http_referer",‘
        ‘"agent":"$http_user_agent",‘
        ‘"elapsed":"$request_time",‘
        ‘"serverelapsed":"$upstream_response_time"}‘;

    geoip2 /usr/local/nginx/conf/GeoLite2-Country.mmdb {
        auto_reload 5m;
        $geoip2_metadata_country_build metadata build_epoch;
        $geoip2_data_country_code default=US country iso_code;
        $geoip2_data_country_name country names en;
    }

    geoip2 /usr/local/nginx/conf/GeoLite2-City.mmdb {
         $geoip2_city_name default=BeiJing city names en;
         $geoip2_continent_code continent code;
    }

 

Nginx配置GeoIP

原文:https://www.cnblogs.com/wjoyxt/p/14087434.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!