Skip to content

🐳 A self-host πŸ™… non-tracking, AD-πŸ†“ βž• πŸͺ-πŸ†“ solution to show your IP ℹ️ Super small (🀏10MB)

License

Notifications You must be signed in to change notification settings

PeterDaveHello/ipinfo.tw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

77 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ipinfo.tw

license Build Status Docker Hub pulls

Docker Hub badge

A self-hosted, non-tracking, and ad-free solution to reveal client-side IP info like IP address, country, AS number/description, and additionally, user agent.

Table of Contents

Demo

This project is also hosted publicly on https://ipinfo.tw, feel free to give it a try!

Please note that for response integrity and privacy concerns, this demo is behind an reverse proxy with https enabled, which is not part of this project. http traffic will be redirected to use https to establish the connection, in case the plaintext data being sniffed/intercepted.

Usage

Deploy to DigitalOcean

You can now directly deploy ipinfo.tw project on DigitalOcean App Platform using the deploy button:

Deploy to DO

On DigitalOcean App Platform, we use the HTTP header DO-Connecting-IP as client's IP address, for more technical details, check the DigitalOceanAppPlatform branch.

Server side

Run the server daemon via docker:

docker run -d --name ipinfo.tw -p 80:8080 peterdavehello/ipinfo.tw:latest

If you want to put this container behind reverse proxy, set up an X-Real-IP header and pass the it to the container, so that it can use the header as the IP of the client.

Client side

Use any http(s) client to explore the server, e.g. https://ipinfo.tw,

  • wget -qO- https://ipinfo.tw
  • curl https://ipinfo.tw

Without any specified URI, the server will return IP address, country, AS, and user agent.

If you prefer to receive a machine-readable result, use path /json (without trailing slash), e.g. https://ipinfo.tw/json, the result will look like:

{"ip":"3.115.123.234","country_code":"JP","country_name":"Japan","asn":"16509","as_desc":"Amazon.com, Inc.","user_agent":"curl/7.58.0"}

Endpoints

You can also specify the following URI to retrieve certain info:

  • ip: IP address
  • country: Country code and name
  • country_code: Country code
  • country_name: Country name
  • as: AS number and description
  • asn: AS number
  • as_desc: AS description
  • user_agent: User agent string

Examples:

$ wget -qO- https://ipinfo.tw
157.230.195.167
SG / Singapore
AS14061 / DigitalOcean, LLC
Wget/1.17.1 (linux-gnu)

$ curl https://ipinfo.tw/ip
18.179.200.1

$ curl https://ipinfo.tw/country
TW / Taiwan

$ curl https://ipinfo.tw/country_code
HK

$ curl https://ipinfo.tw/country_name
South Korea

$ curl https://ipinfo.tw/as
AS16509 / Amazon.com, Inc.

$ curl https://ipinfo.tw/as
AS8075 / Microsoft Corporation

$ curl https://ipinfo.tw/asn
15169

$ curl https://ipinfo.tw/as_desc
Google LLC

$ wget -qO- https://ipinfo.tw/user_agent
Wget
Database build time endpoint

There is a special endpoint - /build_epoch, which will return a json object that contains two unsigned 64-bit integers of the database build timestamp as the Unix epoch value.

The response of /build_epoch will be look like:

{"GeoLite2-Country":"1655395486","GeoLite2-ASN":"1655730848"}

As mentioned above, on the demo domain - ipinfo.tw, if https:// is not specified in the URL, connection will be redirected from http to https, in this case, curl will need an additional parameter: -L/--location to follow location redirection.

Build

If you want to build your own image, instead of directly pull the pre-built one, clone this repository, and run docker build command, with build-arg MAXMIND_LICENSE_KEY, you need to provide your own MaxMind license key from https://www.maxmind.com/en/account, it's free.

$ git clone --depth 1 https://github.com/PeterDaveHello/ipinfo.tw
$ cd ipinfo.tw
$ docker build --build-arg MAXMIND_LICENSE_KEY="$MY_MAXMIND_KEY" -t ipinfo.tw:custom-build .

Credits

This project uses works from projects below, and fully appreciates contributors behind these projects:

Sponsor

This project is now sponsored by DigitalOcean with the hosting since Feb 2023.

If you're looking for cloud VPS hosting, you can use my DigitalOcean referral link to get $200 credit: https://m.do.co/c/1fdd0a1d695a

License

This project is released under the GPL-3.0 license.