Coder Social home page Coder Social logo

openresty-geoip2-docker's Introduction

dockerhub已经打包好的

https://hub.docker.com/r/coloynle/openresty-geoip2

openresty-geoip2

文档和这个一致,只在上面加了geoip2的模块 https://github.com/openresty/docker-openresty

geoip2的使用方法

##
# GeoIP
## nginx配置文件里的http模块下定义如下代码
http{
    geoip2 /usr/share/GeoIP/GeoLite2-Country.mmdb {
        auto_reload 5m;
        $geoip2_metadata_country_build metadata build_epoch;
        $geoip2_data_country_name country names en;
        $geoip2_data_country_code country iso_code;
    }
    
    geoip2 /usr/share/GeoIP/GeoLite2-City.mmdb {
        auto_reload 5m;
        $geoip2_continent_code continent code;
        $geoip2_country country names en;
        $geoip2_country_code country iso_code;
        $geoip2_region subdivisions 0 names en;
        $geoip2_region_code subdivisions 0 iso_code;
        $geoip2_city city names en;
        $geoip2_postal_code postal code;
        $geoip2_latitude location latitude;
        $geoip2_longitude location longitude;
        $geoip2_timezone location time_zone;
    }
    
    geoip2 /usr/share/GeoIP/GeoLite2-ASN.mmdb {
        auto_reload 5m;
        $geoip2_asn autonomous_system_number;
        $geoip2_organization autonomous_system_organization;
    }
}

## 使用 在server模块里可以这样用
server {
        listen       80;
        server_name  test.test.com;
        add_header x-geoip-continent_code $geoip2_continent_code;
        add_header x-geoip-country $geoip2_country;
        add_header x-geoip-country_code $geoip2_country_code;
        add_header x-geoip-region $geoip2_region;
        add_header x-geoip-region_code $geoip2_region_code;
        add_header x-geoip-city $geoip2_city;
        add_header x-geoip-postal_code $geoip2_postal_code;
        add_header x-geoip-latitude $geoip2_latitude;
        add_header x-geoip-longitude $geoip2_longitude;
        add_header x-geoip-timezone $geoip2_timezone;

        if ($geoip2_city != ''){
            return 200 "$geoip2_city";
        }
}

openresty-geoip2-docker's People

Contributors

coloynle avatar

Watchers

 avatar

Forkers

alan0031

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.