Live data from Hacker News

I made a simple geolocation service

maxkostinevich.com

81–90 of 187 posts

Re: I made a simple geolocation service

#81
post #41

Since most CDNs are already doing GeoIP lookups (for request headers or log entries), you can leverage that to provide the data back in the response body via origin, worker or even CDN edge config. Programmatically populating the response body, as in the Cloudflare worker example from the post, is better than going to the origin just to echo some headers back in the response. To me, something like Fastly's VCL config…

Your service correctly returned the following data about my IP:

    "client": {
      "conn_speed": "broadband",
      "conn_type": "wifi",
      "proxy_description": "vpn",
      "proxy_type": "hosting"

Is this what Fastly is thinking about my IP?

Re: I made a simple geolocation service

#82
post #80

TECHNIQUE: use the proprietary HTTP Request headers available through CDN/Cloud providers like Cloudflare Workers' cf-country [1], Amazon CloudFront's CloudFront-Viewer-Country [2], and Google App Engine's X-Appengine-Country/-Region/-City/... [3] to get client Geolocation data. [1] https://developers.cloudflare.com/workers/reference/apis/req... [2] https://docs.aws.amazon.com/AmazonCloudFront/latest/Develope... [3]…

Thank you - I was about to ask if this sort of information was available through other cloud providers.

Re: I made a simple geolocation service

#83
post #59

Earlier quoted context omitted.

The main advantage of the cloud for me that it provides PaaS services. You don't have to administer a VM, etc, you just use the services and it's someone else's job to install security updates and stuff.

Installing updates and stuff is easy to automate.

And sometimes automatic updates break and then the site may be down until you find the problem which may require much reading and therefore a longer time if you don't deal with sysadmin stuff often.

With PaaS it's someone else's job who does this every day.

Re: I made a simple geolocation service

#84
doing a geo based redirection was my first golang project that got deployed to prod.

Nginx + GeoIP2 module sets a HTTP request header and proxies the request to the golang app.

The go app does a lookup from redis, based a combination of country header and some url params and responds back with a redirect header.

Hosted it on a t2 medium in EC2 and I have seen it easily handle ~1500 requests / second without any issue.

Re: I made a simple geolocation service

#85
post #64

Earlier quoted context omitted.

Am I missing something? Isn't a $3 VM referring to a VM service in a cloud somewhere? If you try to do the same thing without cloud you'll have to end up renting space in a datacenter, install your own servers, connect to an ISP, power bills, etc etc. Cloud definitely seems cheaper in comparison

GP and you aren't using the same definition of cloud. By cloud, they mean infrastuctures like AWS/GCP/Azure, not simple VM hosting (called VPS outside "clouds", and compute nodes in "clouds")

What's the definition of "cloud" then which excludes VPS from the umbrella of services offered in cloud? Not really sure how a VPS is any different from a Google Compute Engine

Re: I made a simple geolocation service

#86
post #81
post #41

Since most CDNs are already doing GeoIP lookups (for request headers or log entries), you can leverage that to provide the data back in the response body via origin, worker or even CDN edge config. Programmatically populating the response body, as in the Cloudflare worker example from the post, is better than going to the origin just to echo some headers back in the response. To me, something like Fastly's VCL config…

Your service correctly returned the following data about my IP: "client": { "conn_speed": "broadband", "conn_type": "wifi", "proxy_description": "vpn", "proxy_type": "hosting" Is this what Fastly is thinking about my IP?

Yeah, that's coming from these four Fastly VCL variables:

conn_speed: https://developer.fastly.com/reference/vcl/variables/geoloca...

conn_type: https://developer.fastly.com/reference/vcl/variables/geoloca...

proxy_desc: https://developer.fastly.com/reference/vcl/variables/geoloca...

proxy_type: https://developer.fastly.com/reference/vcl/variables/geoloca...

conn_type is interesting to me, I'm not sure how you would distinguish wifi vs. wired based on HTTP header data.

Re: I made a simple geolocation service

#87

Can you make a geolocation service from static files? 2^32 IP4 addresses with 2 floats per address would take only 34 gigabytes of storage. Put 256 addresses in a given file, and turn the other three octets into folders. E.g. https://example.com/192/168/0.txt would contain the location for addresses 192.168.0.0-192.168.0.255. Would this be cheaper than running these services?

MaxMind sells their databases as files as well as APIs. GeoLite is free to use but not as accurate as their paid products.

Re: I made a simple geolocation service

#88
post #86
post #81

Earlier quoted context omitted.

Your service correctly returned the following data about my IP: "client": { "conn_speed": "broadband", "conn_type": "wifi", "proxy_description": "vpn", "proxy_type": "hosting" Is this what Fastly is thinking about my IP?

Yeah, that's coming from these four Fastly VCL variables: conn_speed: https://developer.fastly.com/reference/vcl/variables/geoloca... conn_type: https://developer.fastly.com/reference/vcl/variables/geoloca... proxy_desc: https://developer.fastly.com/reference/vcl/variables/geoloca... proxy_type: https://developer.fastly.com/reference/vcl/variables/geoloca... conn_type is interesting to me, I'm not sure how you would…

I haven’t worked in the space in a while but I’d doubt it’s via anything like HTTP headers. From a total guess I’d look at packet inter frame gaps & jitter to imply client csmacd or l2 behavior. Maaaaybe MTU and TTLs to infer intermediate routed networks or devices like the tunnel. And of course various TCP options and behavior, like say timestamps and dsack, to fingerprint the client or intervening ip proxies.

Re: I made a simple geolocation service

#89
post #22

Google App Engine had this quite a while ago (almost a decade, I think)and a very generous free tier. Also has approx lat-long, city, state and country. https://blip.runway7.net https://github.com/runway7/blip I lost track of the consumer apps I've used this on and still haven't received a $1+ bill.

Is there a good lat/lon to timezone database that lets you leverage this into a presumptive timezone offset from UTC and thus local time?

Re: I made a simple geolocation service

#90
post #41

Since most CDNs are already doing GeoIP lookups (for request headers or log entries), you can leverage that to provide the data back in the response body via origin, worker or even CDN edge config. Programmatically populating the response body, as in the Cloudflare worker example from the post, is better than going to the origin just to echo some headers back in the response. To me, something like Fastly's VCL config…

[deleted]
Post reply on HN