Location from IP Address
location-from-ip-address-service is an open-source Spring Boot service that resolves an IP address to a geographic location through a GeoIP lookup and renders the result on a map.
- A Spring Boot service that resolves geographic location details from an IP address using GeoIP lookup, with a map view of the result.
- Java
- Teams doing analytics or fraud checks who would rather not send every user IP to a vendor
- Anyone localising content by region without a per-request bill
- Java developers who want a working GeoIP example rather than a snippet
- Java 17+
- Maven (wrapper included)
Overview
A self-hosted alternative to paying a third-party API per request for something as routine as turning an IP address into a country and city. The service exposes a lookup endpoint, models the resolved location as a first-class type, and includes a map view so you can see the answer rather than read coordinates.
What it does
- Lookup endpoint returning structured location data for an IP address
- A dedicated map view rendering the resolved location visually
- Server location modelled as its own type instead of a loose map of strings
- Self-hosted, so user IP addresses never leave your infrastructure
Quickstart
Clone and run
git clone https://github.com/dibyapp/location-from-ip-address-service.git
cd location-from-ip-address-service
./mvnw spring-boot:runWhy self-host a GeoIP lookup
IP geolocation through a commercial API is easy to adopt and awkward to live with. It puts a per-request cost on a lookup that should be nearly free, adds a network hop to a hot path, and quietly turns every user's IP address into data you are sending to someone else.
A local GeoIP database answers the same question with none of those properties. This service is the thin layer around it that most projects end up writing anyway.
How do I get a location from an IP address in Java?
Query a local GeoIP database rather than a remote API. This Spring Boot service does exactly that: it takes an IP address, resolves it against a GeoIP lookup, returns structured location data, and can render the result on a map.
Does it send user IP addresses to a third party?
No. The lookup runs against a local GeoIP database inside your own infrastructure, which is the main reason to run it instead of calling a hosted geolocation API.