GithubHelp home page GithubHelp logo

guoyu07 / ngx_http_ipip_module Goto Github PK

View Code? Open in Web Editor NEW

This project forked from youzan/ngx_http_ipip_module

0.0 0.0 0.0 1.64 MB

nginx http module for ipip.net

License: Other

Makefile 0.11% C 94.69% Shell 1.62% Perl 3.58%

ngx_http_ipip_module's Introduction

ngx_http_ipip_module

Build release

ngx_http_ipip_module is an addon for nginx to ipip

Table of Contents

How-To-Use

Set the nginx config for ngx_http_ipip_module as the following:

http {
    ipip_ip_datx /xx/real_ip.datx;
    ipip_phone_txt /xx/real_phone.txt;

    server {
        listen 1999;

        location / {
                ipip on;
        }
    }
}

now you can get the ip info as the following:

[root@localhost ~]# curl "http://127.0.0.1:1999/ip?ip=8.8.8.8"
{
    "ret":  "ok",
    "data": ["GOOGLE", "GOOGLE", "", "google.com", "level3.com", "", "", "", "", "", "", "*", "*"]
}

or you can get the phone info as the following:

[root@localhost ~]# curl "http://127.0.0.1:1999/phone?phone=13000000101"
{
    "ret":  "ok",
    "data": ["北京", "北京", "**联通网络"]
}

How-To-Autoupdate

According the check-version api of ipip, we can check the ip and phone version automaticly. We're recommanded to use crontab to autoupdate as the following:

1 3 * * * xx flock -n /xx/ipip.lock /path/to/ngx_http_ipip_module/scripts/autoupdate.sh &> /data/logs/ipinfo.log

By the way, you must set the private data which is the token on ipip to the scripts/var file as the following:

export IPTOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaa
export PHONETOKEN=bbbbbbbbbbbbbbbbbbbbbbbbbbbb
export PATH=/opt/nginx/sbin:$PATH

Also you can rewrite the autoupdate.sh to suit for yourself. And the fake_ip.datx and fake_phone.txt are the fake file in order to run tests (we are recommanded to buy the service from ipip for getting the real file).

Requirements

ngx_http_ipip_module requires the following to run:

Directive

ipip_ip_datx

Set the ip datx file

Syntax: ipip_ip_datx /path/to/file

Default: -

Context: main

http {
    ipip_ip_datx /xx/real_ip.datx;
}

ipip_phone_txt

Set the phone txt file

Syntax: ipip_phone_txt /path/to/file

Default: -

Context: main

http {
    ipip_phone_txt /xx/real_phone.txt;
}

ipip

Enable the ngx_http_ipip_module

Syntax: ipip on|false

Default: -

Context: loc

location / {
    ipip on;
}

Contributing

To contribute to ngx_http_ipip_module, clone this repo locally and commit your code on a separate branch.

License

This module is licenced under the BSD license.

Copyright (C) 2016 by Yang Bingwu (detailyang) [email protected], YouZan Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ngx_http_ipip_module's People

Contributors

detailyang avatar

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.