Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lilien1010/lua-resty-maxminddb
a lua module to get ip location with maxmind db
https://github.com/lilien1010/lua-resty-maxminddb
Last synced: about 1 month ago
JSON representation
a lua module to get ip location with maxmind db
- Host: GitHub
- URL: https://github.com/lilien1010/lua-resty-maxminddb
- Owner: lilien1010
- Created: 2016-11-06T14:07:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-06T03:05:21.000Z (over 4 years ago)
- Last Synced: 2024-02-15T01:35:34.268Z (9 months ago)
- Language: Lua
- Size: 10.7 KB
- Stars: 12
- Watchers: 4
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-resty - lua-resty-maxminddb
README
# A lua client for maxmind db
to get ip location with ip database offerd by maxmind
# Installation1. install libmaxminddb from this [repo](https://github.com/maxmind/libmaxminddb)
2. download ip database from [maxmind](https://www.maxmind.com/en/geoip2-databases)# Demo code:
```lua
local maxminddb = require("resty.maxminddb")
local geo_file = '/home/lua/common_data/GeoIP2-Country-20161004.mmdb'
local ip_db = maxminddb.new(geo_file)local client_ip = ngx.req.get_uri_args()['ip']
local out = {}
if not client_ip then
return nil
end
local res,err = ip_db:get_area_code(client_ip)
ngx.print( res )
```
# Bug Reports
Please report bugs by filing an issue with our GitHub issue tracker at
https://github.com/lilien1010/libmaxminddb/issues
or if the bug is casued by libmaxminddb tracker at
https://github.com/maxmind/libmaxminddb/issues# Copyright and License
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.