javagoogle-app-engineip-geolocation

geolocation of an IP address while using GAE sdk or otherwise


I have hosted my web-app on google appengine (GAE). Does GAE sdk offer any way to find the geolocation of an IP ? If yes please suggest how can I do this .


Solution

  • Yes, you can use request headers to get the geolocation of the IP.

    https://cloud.google.com/appengine/docs/standard/go/reference/request-response-headers#app_engine-specific_headers

    X-AppEngine-Country Country from which the request originated, as an ISO 3166-1 alpha-2 country code. App Engine determines this code from the client's IP address.

    Other headers that are useful for location are X-AppEngine-Region, X-AppEngine-City and X-AppEngine-CityLatLong

    I don't think this will return valid values when running on your local sdk.