
I made a simple geolocation service - maxko
https://maxkostinevich.com/blog/serverless-geolocation/
======
tastytacos
I applaud your efforts but it's disingenuous to title this how you "made a
geolocation service" when you are just reading a field in someone else's
geolocation service.

~~~
georgyo
Indeed. Using another service and being a wrapper around it is not all that
impressive. He is also using workers which makes his solution expensive.

I run ifconfig.io which now gets just over a billion hits a day. It is
basically an echo service, and it just parrots back what cloudflare tells it.
But since I run it on linode, it costs me a whopping $40 dollars a month for
35 billion returns a month. Using workers would cost me several thousand
dollars.

[http://ifconfig.io/country_code](http://ifconfig.io/country_code)

~~~
mongo-db-hater
Thanks for sharing. This is a perfect example which proves
lambda/serverless/cf worker are snake oils.

~~~
iforgotmyaka
It's not.

If under 10 million requests per month, serverless will be cheaper and safer

Else if under 1 billion request per month, managed VPS will be cheaper

If over hundred of billions of requests per month, anything else than on
premise is probably an error.

Then you have grey areas where you need to process.

But for most small project, you cannot beat the lambda prices. Especially if
you expect bursts.

~~~
foepys
But if I expect bursts, Lambda could potentially cost me a few thousand
dollars in a day while my own instance could handle it fine for like $50. Even
paying $50/mo over a few _years_ would pay off in that case.

~~~
mongo-db-hater
Exactly. developer time lot more expensive. most people want to look cool & do
cool things so they drink these cool aids.

it sounds lot cooler to say that " i made geolocation service using
serverless/lamba" than "i made geolocation service using boring monolithic
technology". where the former takes 150 hours to get it right and painful to
add/manage features. where the later is very easy to maintain and very
predictable priced.

------
sudhirj
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://blip.runway7.net)
[https://github.com/runway7/blip](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.

~~~
sneak
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?

~~~
deanishe
Can’t you just ask the client which timezone it’s in? Every browser knows, and
it will be a more accurate answer: the user might be on a foreign VPN or
temporarily in another TZ, but not working on that timezone.

~~~
sneak
My application is not browser-based.

I’d like to set a system clock timezone via geoip only, without location
lookup via wifi. On my more secure systems I have location services disabled
and it’d be nice to have an accurate local time automatically.

~~~
sroussey
I have a need for this too, and considering making a basic service for it.

~~~
sudhirj
[https://blip.runway7.net/v2.beta](https://blip.runway7.net/v2.beta) should
work for you, let me know if it doesn't?

~~~
sroussey
Hi!

I need to be able to send a lat/long/timestamp to get tinezone.

~~~
jaakl
This is surprisingly difficult task if you need it to work really globally and
accurately. You need specific, detailed and uptodate map data for it, and
timezones change somewhere in the world all the time. Especially daylight
savigs. In 99% of cases you need to find some workaround or limit your task to
specific regions, and get something to work in 95% cases

------
skuhn
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
language is even simpler. It directly executes on every CDN edge node
worldwide upon request.

For example, I just whipped this up on Fastly using VCL. It returns GeoIP as
json data for your IP at the root path:

[http://geo.zombe.es](http://geo.zombe.es)

Or if you want a particular IP, just append it to the path:

[http://geo.zombe.es/2a04:4e42:600::313](http://geo.zombe.es/2a04:4e42:600::313)

You could do the same via query params, headers, etc. Have URL endpoints that
only return some of the data, and so forth.

The VCL syntax gets a little gross when you handle quoting strings and
assembling json and testing if the string is empty, but it gets the job done.

Of course what you might want from GeoIP data may not be what you get. It's
really kind of a useful kludge that gets treated sometimes as a panacea.

This dataset right now thinks that I'm about 5 miles east of my location, but
when subnets are repurposed it could be much more significant. And the data
sources are always changing, so who knows what it will think tomorrow.

~~~
jgrahamc
What does the code for this look like?

~~~
skuhn
The VCL for it is available at
[https://gist.github.com/simonkuhn/a380a6fa205db87a3625f26ad0...](https://gist.github.com/simonkuhn/a380a6fa205db87a3625f26ad09e6593)

vcl_recv and vcl_error are the important bits, the rest is VCL boilerplate
from
[https://developer.fastly.com/learning/vcl/using/](https://developer.fastly.com/learning/vcl/using/)
for unused subroutines.

------
jasonlingx
This one I made couple years ago (and haven’t checked in years) is still
running for free thanks to Heroku and Cloudflare:
[https://github.com/jlxw/geoip](https://github.com/jlxw/geoip)

------
itsjloh
I (like many others it seems!) have also built a geolocation service however
mine is built on top of MaxMind's DBs that are mentioned in the post. Its on a
few boxes running OpenResty and now handles 130m+ requests/day. Was really fun
to build!

[https://github.com/jloh/geojs](https://github.com/jloh/geojs)
[https://www.geojs.io/open/](https://www.geojs.io/open/)

~~~
rvnx
It's forbidden by MaxMind ToS, these dudes changed the rules and forces you to
abide to the new conditions when you download an update.

It's very borderline from them (at least ethically)

~~~
cpburns2009
At the bottom of the page it credits the MaxMind GeoLite database. The
GeoLite2 database is licensed as CC BY-SA 4.0. It's the GeoIP2 database that
has stricter licensing.

[https://dev.maxmind.com/geoip/geoip2/geolite2/](https://dev.maxmind.com/geoip/geoip2/geolite2/)

------
waffl
I had to tackle this problem as well for a small project and found that I
could just send a GET request to [https://www.cloudflare.com/cdn-
cgi/trace](https://www.cloudflare.com/cdn-cgi/trace) and parse the response
with a simple regex: /loc=(\w*)$/gm

The response time averages 10ms and is free, granted I'm not sure if there is
a ToS or anything attached to this endpoint, I've only found non-conclusive
discussion here [https://community.cloudflare.com/t/what-are-the-terms-of-
use...](https://community.cloudflare.com/t/what-are-the-terms-of-use-for-cdn-
cgi-trace/147936)

~~~
jgrahamc
I mean, you can do that but it's a hideous hack and we might change that
output at any time and you could easily hit DDoS mitigation or other security
features if you do that. That endpoint is used for debugging and is in no way
an API.

I'd advise you to just create a Cloudflare Worker if you want do this. You'll
get more reliability etc. and Workers have a very generous free tier.

------
speedgoose
Well that's a bit more than 2 requests per second on average. Sure you may
have some bursts once in a while, but nothing a 3€ VM can't manage IMHO.

~~~
Nextgrid
I always find it funny when people brag about cost savings on cloud services
while overlooking the insane premium they're paying by using the "cloud" to
begin with.

It's kinda like a construction firm using a supercar to haul materials and
then bragging about their efforts to make cosmetic repairs cost-effective...
maybe you could just not use an overpriced car to begin with and then damage
won't be an issue?

~~~
harpratap
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

~~~
progval
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")

~~~
harpratap
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

~~~
XCSme
I think the main difference is the pricing structure. Usually "cloud" refers
to the auto-scaling servers with the pay-as-you go pricing, while VPSs are
usually manually instantiated and have a fixed monthly cost. Also, sometimes
with VPSs you get more control over the server's settings than with "cloud"
services.

So "cloud" is like renting a dynamically changing number of VPSs each month
and which are usually more costly if your consumption is not spiky (eg. when a
cheap VPS rented 24/7 is enough).

------
ignoramous
Full marks to Cloudflare for engineering a radically effective and simple
alternative to AWS Lambda (+API Gateway): It is simply a fantastic Serverless
offering for low-latency network-bound workloads. For paying customers, they
even thrown in freemium access to their globally distributed KV store and a
forever-free Zonal Cache to sweeten the already good enough deal. That said,
good luck with their Support team in case you discover undocumented limits (in
production) like these [0].

I got sent a (frustratingly incorrect) bot reply to a ticket and a reminder
that Enterprise / Business / Pro customers are priority (in that order) even
though I pay for Workers. It has been an uphill battle to get someone to take
a look at the ticket so far. Thankfully, we haven't gone to production yet,
but as a consequence, now need to plan to add mitigation in scenarios where
Workers blacks-out our traffic (but Support can't be of immediate help because
"free customer").

[0] [https://community.cloudflare.com/t/workers-and-sub-
requests/...](https://community.cloudflare.com/t/workers-and-sub-
requests/151829)

~~~
vasco
> now need to plan to add mitigation in scenarios where Workers blacks-out our
> traffic (but Support can't be of immediate help because "free customer").

How is it that you prefer to engineer those workarounds instead of just paying
$20/month? It surely can't be worth in engineering hours and ongoing
maintenance of hacky workaround code?

~~~
ignoramous
> How is it that you prefer to engineer those workarounds instead of just
> paying $20/month?

If it isn't clear, there's an issue of trust here, not money. And frankly, a
fallback shouldn't be much of an issue since fly.io, AWS Lambda@Edge are like-
for-like swaps, so we'd still be "serverless" just on a different yet similar
platform (albeit costlier).

------
rightbyte
The cheapest alternative has to be to ask the users where they are and store
it on the user device? I never understood the need for geoip unless you ship
spyware.

If the exact location is important geoip is not accurate enough anyway.
Forwarding to regional sites automatically is just annoying when it doesn't
work properly or someone is traveling abroad.

~~~
davewritescode
If it's just to route to regional sites, that's fine. Letting the user select
just makes sense.

However, there's a lot of use cases that semi-accurate geo-locations make
sense. The first of which is analytics. If I'm a marketing person at a SaaS
company, I want to know where my customers physically are if possible for a
variety of useful reasons.

Good quality estimates for location also help with security and compliance use
cases as well. If a user logs in from a new country on the opposite of the
world, you can flag that and take whatever action you want whether it's to
block them, fire off an email to the person who owns the account or whatever.

~~~
sneak
> _If I 'm a marketing person at a SaaS company, I want to know where my
> customers physically are if possible for a variety of useful reasons._

What reasons? What makes you feel entitled to that information if not
volunteered?

~~~
jaywalk
Any info that can be gleaned from the request is fair game.

------
walrus01
since this article mentions maxmind, this reminded me of when geolocation by
IP address goes horribly wrong, and non-technical persons interpret the
results as something to be relied upon as factual:

[https://arstechnica.com/tech-policy/2016/08/kansas-couple-
su...](https://arstechnica.com/tech-policy/2016/08/kansas-couple-sues-ip-
mapping-firm-for-turning-their-life-into-a-digital-hell/)

[https://www.theguardian.com/technology/2016/aug/09/maxmind-m...](https://www.theguardian.com/technology/2016/aug/09/maxmind-
mapping-lawsuit-kansas-farm-ip-address)

[https://mashable.com/2016/08/11/ip-addresses-
kansas/](https://mashable.com/2016/08/11/ip-addresses-kansas/)

ISP perspective here: Geolocation by granular /24 to /20 sized block of ipv4
space is often wildly inaccurate on a regional basis. It's entirely possible
for the ARIN registration (used by maxmind) to be a street address in Seattle,
but serving end user ISP customers a 4.5 hour drive away in a far eastern
corner of WA state.

------
efesak
Also please see
[https://github.com/analogic/ipgeo](https://github.com/analogic/ipgeo) daily
actualized ip/country database with open license (shameless ad)

~~~
jiofih
That would be a lot more appealing if it explained where the data is sourced
from, included the update scripts, and how it is licensed - the only issue
asking that question was closed without a word.

~~~
ColdHeat
It likely uses the data published by RiRs. I wrote something similar that
discusses where it sources the data and how to generate it.
[https://github.com/geoacumen/geoacumen-
country](https://github.com/geoacumen/geoacumen-country)

I've been meaning to make automatic Github releases for it.

------
wingi
I had a geo-location service running in google app engine. for free. After
pimping caching the daily traffic of 400.000 requests/day was in the free-
tier.

[https://www.united-coders.com/christian-harms/detailed-
perfo...](https://www.united-coders.com/christian-harms/detailed-performance-
optimization-steps-on-webservice/)

------
fs2
I've used the free MaxMinds database for a while but since the last year I've
been using iplist.cc. It supports IPv4, IPv6, shows if an IP is tor, spam,
which ASN and a lot more.

It's also free and fast but with services like these I always wonder how long
they manage to stay free.

~~~
nkozyra
Right. The first worry is "will this be here tomorrow?" The second is "how
much more will they end up charging?"

I had good success with maxmind's free database. I can't find tooth results
for accuracy but my sampling was pretty good. They also have an incentive to
keep it.

------
bellwether
Love the ingenuity and thank you for the performance comparison on Cloudflare
Workers vs AWS Lambda. I personally wouldn’t consider what you built a
Geolocation service, but glad it solved your use case!

~~~
maxko
Thanks!

------
jamesponddotco
I built a simple API using pure NGINX to get the IP address of a client, for
times when I needed to ask a customer for his IP address; it was easier
sending them a URL for a service I control, than explaining how they could get
that information another way.

Now I have been thinking about opening it up for more people because while
there are a variety of these services out there, one more does not hurt — it
already exists, and works, so who knows, maybe more people would like to use
it. The code is open, and access logs go to /dev/null; I could probably add a
read-only SSH user for people to confirm that for themselves.

Geolocation could easily be added to it, but then comes my question: is there
any use-case for geolocation APIs that does not involve tracking users for
shitty purposes?

I was excited about adding this feature because I am using pure NGINX for it,
and it was a fun learning experience, but I asked myself that question when I
started writing the documentation for the website, and I still do not have an
answer. Marketing material for other APIs that offer geolocation usually have
user tracking as a selling point.

Personally, I have no use for geolocation, and if all use-cases involve
tracking without consent users, and breaking their privacy, I want no part in
that.

~~~
jwdavidson
I have exactly one non-shady use case:

I work with an event org with a fairly common name, and another city in our
region has an event with the same name. For some years, we’ve outranked them
for major keywords and getting their confused customers was becoming a
headache for us.

So now if our website thinks you’re in the other city, a little banner appears
above the content asking if you’re looking for the other site, and offers the
link.

This has saved us ~10 phone calls per day in season. Before adding this link
we all got to the point of just doing their customer service for them and
helping people buy tickets because it was less drama than trying to get them
to call the right people.

~~~
jamesponddotco
While I agree that your use-case is not shady, I am not sure how I would work
that in the marketing material for the website — maybe I just suck at writing
marketing copy.

But in any case, your response does tell me that there are other things that
can be done with that information, so maybe I should focus on the IP thing,
and have the geolocation features kinda hidden away in the documentation
pages.

------
gitgud
Side note:

6 million requests per month is only 2.2 requests per second, a raspberry PI
could do this (technically).

~~~
gitanovic
That's only true if you assume a even distribution. If you cluster them the
scenario is a bit different (your conclusion might still hold anyway)

~~~
doctor_eval
Even if all requests were clustered into one hour per day, it’s only 54
requests per second. Pretty sure a Pi would be up to the job.

~~~
louwrentius
Yes, HN hit my blog on a 3b+ and that was no issue.

~~~
SkyLinx
Which blog out of curiosity and 3b requests in which period of time? Is your
blog static? Thanks!

~~~
ta17711771
3b+ is a Raspberry Pi model.

------
whatl3y
So this finds the country based on some cloudflare-populated info of an
incoming request (which sounds like it solved OP’s problem which is good), but
if you want to use MaxMind’s database to find the country of _any_ public IP I
built the following a few months back:

[https://github.com/Risk3sixty-Labs/geoapi](https://github.com/Risk3sixty-
Labs/geoapi)

------
sradman
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...](https://developers.cloudflare.com/workers/reference/apis/request/)

[2]
[https://docs.aws.amazon.com/AmazonCloudFront/latest/Develope...](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html#request-
custom-headers-behavior)

[3]
[https://cloud.google.com/appengine/docs/standard/go/referenc...](https://cloud.google.com/appengine/docs/standard/go/reference/request-
response-headers)

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

------
ignoramous
One of the main challenges of building on Serverless platforms is rate-
limiting.

There's nothing stopping a script-kiddie from thundering away at the
Serverless endpoint resulting in an unexpected and quite high billables [0].

As for Workers specifically, Cloudflare's rate-limiting plan makes the whole
thing 10x expensive at $10 for 2,000,000 good-requests [1] + $1 for 2,000,000
Workers requests. Other cloud providers I don't think fare any different.

[0] [https://community.cloudflare.com/t/how-to-protect-
cloudflare...](https://community.cloudflare.com/t/how-to-protect-cloudflare-
worker-from-ddos/179017)

[1] [https://support.cloudflare.com/hc/en-
us/articles/11500027224...](https://support.cloudflare.com/hc/en-
us/articles/115000272247)

------
contravariant
I'm a bit confused. This looks like a few hundred lines of code to read a
value from a hardcoded dictionary. Even as a proof of concept it would be more
sensible to just add two numbers or something, at least that gives the
impression that you could also make the API do something useful.

------
scottndecker
MaxMind data accurate to the zip code level only about 30-60% of the time (as
compared with what Google's Geolocation service will provide which is based
off more data points than just IP address). Only use MaxMind if you're looking
for region or country level accuracy.

------
EE84M3i
What are the runtime limitations that prevent the maxmind database from
working inside cloudflare workers?

~~~
achairapart
I was wondering the same.

------
mcculley
Regarding latency of AWS Lambda:

> on average the response took somewhere between from 200ms to 500ms

I'm getting latency of 66ms to 126ms with some simple Java code running on AWS
Lambda using provisioned concurrency. I find the latency is just fine for most
use cases.

~~~
vp8989
"using provisioned concurrency"

What's the point of using Lambda if you have to provision capacity for it?

You pay a premium on the compute because it's able to scale down to zero (so
in theory, it works out cheaper anyway), but in reality it only works well
when you do everything in your power to have it not scale down to zero.

~~~
mcculley
For my use case, it is still much cheaper than having a dedicated VM.

------
csunbird
Interesting, so basically you are making Cloudflare's geoip service public for
free.

~~~
EE84M3i
You can do this on appengine too, it provides the client location in a header.

------
grizzles
How does MaxMind prevent someone from releasing an open source version of
their database? If you are about to answer "Copyright", remember - you can't
Copyright facts. This has been upheld in the Courts system many times.

~~~
mike_d
Facts cannot be copyrighted, but a unique compilation of facts can be. This
became settled law many decades ago with sports almanacs.

Furthermore, Maxmind adds non-factual entries to the database so they can
identify it uniquely as their work. Map makers do something similar:
[https://en.wikipedia.org/wiki/Trap_street](https://en.wikipedia.org/wiki/Trap_street)

------
ColdHeat
I've been trying to build open source MaxMind alternatives for a bit. (Mostly
so I could distribute them with my open source projects)

IP to country is fairly easy and I open sourced all the scripts and the
database itself [0].

But IP to city is much harder, I'm not actually sure it's viable for anyone to
do that without relying on some other 3rd party service.

I'd be very interested to hear if anyone knows how to pull that off in an open
sourceable manner.

[0] [https://github.com/geoacumen/geoacumen-
country](https://github.com/geoacumen/geoacumen-country)

~~~
unilynx
A big part of why you can't freely distribute Maxmind's Lite databases is them
trying to apply CCPA requirements.

That law will affect open source solutions just as much.

~~~
ColdHeat
IANAL but Maxmind has to comply with CCPA I assume because they are sourcing
data from California residents. If data is sourced in an aggregate or
anonymous way, it wouldn't be subject to CCPA.

> Aggregate and anonymous data is exempt from the CCPA, unless it is in any
> way re-identifiable. [https://www.cookiebot.com/en/what-is-
> ccpa/](https://www.cookiebot.com/en/what-is-ccpa/)

------
Nextgrid
Why would you need to depend on a third-party service and network being
available for such a basic task? MaxMind provides their GeoLite database for
free and it's extremely easy to embed it in your app.

------
GiantSully
Though a little bit off-topic, before the service
[http://freegeoip.net/json/](http://freegeoip.net/json/) ceased, I used it a
lot in testing. I built one myself with the simplified source code from
[https://github.com/voyagin/freegeoip](https://github.com/voyagin/freegeoip)
since I want to minimize the response time. BTW, the listed repo isn't mine.

~~~
andruby
I run a hosted version on
[https://freegeoip.whoisbot.io](https://freegeoip.whoisbot.io) but it looks
like MaxMind changed their database url so it stopped working

------
layoutIfNeeded
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](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?

~~~
hansitomani
You could also generate all those files, put that into a GCS Bucket and put an
API Gateway in front.

easier would be and thats just a thought: You could build a go/c++/java app
which contains that database pre compressed in some arbitrary better format
than just 2 floats, get it down from your original 34gig and just keep it in
memory.

Like if you know that 99% of all ips in a certain range are from US, then only
store the 1% as a list.

~~~
layoutIfNeeded
Sure, but my point was that it can be done with zero compute cost. There's
nothing cheaper than serving static files from cloud storage.

~~~
hansitomani
That is just not true.

GCS for example and its the same with S3, costs space, egress and requests
themself.

Data Storage 50 GB Standard Storage * $0.026 per GB $1.30 Network 10 GB egress
* $0.12 per GB $1.20 Operations 10,000 Class A operations * $0.05 per 10,000
operations $0.05 Operations 50,000 Class B operations * $0.004 per 10,000
operations $0.02

------
sheeshkebab
This only work’s if geocoder is accessed directly from browser. It will not if
you need to geocode ip addresses received in other ways on the server side.

I guess it’s ok for a basic consumer website, although it’s not exactly
equivalent to ip geocoder databases/services - they allow passing ip addresses
as part of geocoding request.

------
freelancercv
You can do this for FREE [https://freelancer.freelancercv.com/blog/9/find-
website-visi...](https://freelancer.freelancercv.com/blog/9/find-website-
visitors-country-location-using-cloudflare-free-service)

------
pereiratr
Nice! Have you tried AWS Lambda@Edge?

~~~
pereiratr
and it looks like similar geolocation info "cloudfront-viewer-country" is
available from AWS as well. So similar trick maybe possible with AWS
[https://docs.aws.amazon.com/AmazonCloudFront/latest/Develope...](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-
examples.html#lambda-examples-redirect-based-on-country)

------
tuananh
it's right here in the worker example

[https://developers.cloudflare.com/workers/templates/pages/co...](https://developers.cloudflare.com/workers/templates/pages/country_code/)

------
fasteo
Slightly off-topic.

AFAIK, an unresolved problem is a proper geolocation service - at least for
city level resolution - for mobile IP addresses. There are some services in
this field (digital element), but they are _very_ unreliable.

------
stereo
That country list doesn't have Kosovo (2008) or South Sudan (2011).

~~~
jacobush
Kosovo is not universally recognised though, to be fair. But yes, I'd include
it. Even if you are against in principle, it's de facto a state and treated as
such even by many countries not recognising it in name.

~~~
hansitomani
But that would mean that your API should return a country specific result to
be accurate.

~~~
AdrianoKF
Which is precisely what for example Mapbox does - they allow consumers to
specify a worldview, which adjusts borders and other geographic features based
on the specified culture:
[https://docs.mapbox.com/help/glossary/worldview/](https://docs.mapbox.com/help/glossary/worldview/)

~~~
jaakl
They dont have Serbian one to resolve this issue. Or even more relevant ones
like Russia (remember Crimea).

------
ing33k
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.

------
hluska
All possibly criticisms aside, this is really good and useful. Great job
friend!!! It's a beautiful day for hacking!! :)

------
priyaaank
[https://ifconfig.co/](https://ifconfig.co/)

~~~
dt3ft
I got this:

"Application error An error occurred in the application and your page could
not be served. If you are the application owner, check your logs for details.
You can do this from the Heroku CLI with the command heroku logs --tail"

------
llaolleh
This title is so misleading. I got to the end of the article and thought -
wait this is it?!

------
sigmonsays
i read the title and got interested, glad I skimmed. This is very misleading.
You didn't "make" a service, you used someone elses.

------
crispyporkbites
Are you charging for this?

~~~
maxko
The code is available for free and you can host it on your own Cloudflare
account. Cloudflare provides a free plan (up to 100k daily requests across all
your Workers), and paid plan ($0.50 per 1m requests)

------
teknopaul
that two per second if you don't have a calculator handy.

------
PaywallBuster
tl;dr uses Cloudflares workers as API endpoint and returns Country name based
on header in the CF request.

