C Library
PHP Module
Perl Module
Ruby Library
Python Library
Apache Module
Nginx Module
Node.js Module
Cocoa / Objective C Library
Pascal Library
D Library
Go Package
Erlang Module
Haskell Package
Debian Package
Lua Package
Kotlin Module
Scala Library
OpenResty Package
Splunk Add-on
Apache Kafka Transform
OCaml Module
Deno Module
R Package
.NET Component
Java Component
HTTP Module
ActiveX / COM DLL
IP2Location IP Geolocation OpenResty Package
This IP Geolocation package is the OpenResty package to support all IP2Location™ database products. It has been optimized for speed and memory utilization. Developers can use the module to query all IP2Location™ binary databases for applications written using the Lua programming language under OpenResty.
opm get ip2location/ip2location-resty
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080 reuseport;
location / {
default_type text/html;
content_by_lua_block {
local ip2location = require('ip2location')
local ip2loc = ip2location:new('/usr/local/ip2location/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN.BIN')
local result = ip2loc:get_all('8.8.8.8')
ngx.say("country_short: " .. result.country_short)
ngx.say("country_long: " .. result.country_long)
ngx.say("region: " .. result.region)
ngx.say("city: " .. result.city)
ngx.say("isp: " .. result.isp)
ngx.say("latitude: " .. result.latitude)
ngx.say("longitude: " .. result.longitude)
ngx.say("domain: " .. result.domain)
ngx.say("zipcode: " .. result.zipcode)
ngx.say("timezone: " .. result.timezone)
ngx.say("netspeed: " .. result.netspeed)
ngx.say("iddcode: " .. result.iddcode)
ngx.say("areacode: " .. result.areacode)
ngx.say("weatherstationcode: " .. result.weatherstationcode)
ngx.say("weatherstationname: " .. result.weatherstationname)
ngx.say("mcc: " .. result.mcc)
ngx.say("mnc: " .. result.mnc)
ngx.say("mobilebrand: " .. result.mobilebrand)
ngx.say("elevation: " .. result.elevation)
ngx.say("usagetype: " .. result.usagetype)
ngx.say("addresstype: " .. result.addresstype)
ngx.say("category: " .. result.category)
ngx.say("district: " .. result.district)
ngx.say("asn: " .. result.asn)
ngx.say("as: " .. result.as)
ip2loc:close()
}
}
}
}
Discover Your User Locations
Retrieve geolocation data for FREE now!