A lightweight HTTP service that returns the client's public IP address.
Returns the client's IP address. Response format depends on the Accept header:
- Browser (
Accept: text/html) — HTML page with IP, request time, and optional geo/ASN info - Curl / API — plain text, comma-separated
$ curl https://yourhost/
1.2.3.4,2026-02-23T10:15:30Z
$ curl https://yourhost/ # with token
1.2.3.4,2026-02-23T10:15:30Z,United States,US,North America,NA,AS15169,Google LLC
Returns a JSON object with the client's IP address and request time in UTC. Geo/ASN fields are included only when an ipinfo.io token is configured.
$ curl https://yourhost/json
{"ip":"1.2.3.4","time_utc":"2026-02-23T10:15:30Z"}
$ curl https://yourhost/json # with token
{"ip":"1.2.3.4","time_utc":"2026-02-23T10:15:30Z","country":"United States","country_code":"US","continent":"North America","continent_code":"NA","asn":"AS15169","as_name":"Google LLC"}
go run . # listen on :7007
go run . -port 8080 # custom portThe server listens on port :7007 by default.
Image is published to Docker Hub:
docker pull k0st1an/addr2me
docker run --rm -p 7007:7007 k0st1an/addr2me
docker run --rm -p 7007:7007 -e IPINFO_TOKEN=your_token k0st1an/addr2meOr build locally:
make docker-build
make docker-run # default
make docker-run NETWORK=host # host network mode
make docker-run IPINFO_TOKEN=your_token # with geo enrichmentThe image is built on scratch with CA certificates bundled for TLS support.
Geo/ASN enrichment via ipinfo.io is optional. When a token is configured, the HTML page shows country, continent, and ASN info.
IPINFO_TOKEN=your_token go run .Without a token the service works normally — geo info is simply not shown.
The client IP is resolved in the following order:
X-Forwarded-For— proxy / load balancerX-Real-IP— nginxRemoteAddr— direct connection