ngx_stream_ipdb_module - creates variables with values depending on the client IP address, using the precompiled ipip.net ipdb.
- Name
- Status
- Install
- Example Configuration
- Directives
- Variable
- Lua API
- TODO
- Author
- Copyright and License
- See Also
The module is currently in active development.
# install json-c lib
# centos
yum install json-c-devel -y
#or mac OSX
brew install json-c
configure --prefix=/usr/local/nginx --with-stream --add-module=./github.com/vislee/ngx_stream_ipdb_module
# or dynamic compile
configure --prefix=/usr/local/nginx --with-stream --add-dynamic-module=./github.com/vislee/ngx_stream_ipdb_module --with-compat
# or stream_lua
configure --prefix=/usr/local/nginx --with-stream --add-module=./github.com/openresty/stream-lua-nginx-module/ --add-module=./github.com/vislee/ngx_stream_ipdb_module --with-cc-opt='-I ./github.com/openresty/stream-lua-nginx-module/src'
The following information is success:
checking for json-c library ... found
- ngx_stream_ipdb_module was configured
# load_module modules/ngx_stream_ipdb_module.so;
stream {
ipdb conf/ipiptest.ipdb;
ipdb_language "CN";
server {
listen 8091;
# ipdb_language EN;
return "country_name:$ipdb_country_name, raw_info:$ipdb_raw";
}
# stream_lua
server {
listen 8092;
ipdb_language CN;
content_by_lua_block {
local sipdb = require "ngx.stream.ipdb";
ngx.say(sipdb.get_raw("127.0.0.1"));
}
}
}
syntax: ipdb file;
default: -
context: stream
Specifies a database.
syntax: ipdb_language EN|CN;
default: EN
context: stream,server
set variable language.
$ipdb_country_name - country name, for example, "中国", "China"
$ipdb_region_name - country region name, for example, "内蒙古","Nei Mongol", "北京", "Beijing"
$ipdb_city_name - city name, for example, "呼和浩特", "Hohhot", "北京", "Beijing"
$ipdb_isp_domain - ISP name, for example, "电信", "ChinaTelecom"
$ipdb_raw - raw info, for example, "中国\t内蒙古\t呼和浩特","China\tNei Mongol\tHohhot"
syntax: ipdb_raw = ngx.stream.ipdb.get_raw(addr)
context: content_by_lua*, log_by_lua*
Get raw info for addr
. for example, "中国\t内蒙古\t呼和浩特","China\tNei Mongol\tHohhot"
wenqiang li(vislee)
This module is licensed under the BSD 3-Clause License.
Copyright (C) 2019, by vislee.
All rights reserved.