Longshot - Any chance you guys could provide location headers?

Some services like Fastly or Cloud Front are able to provide city based headers. I know there’s nothing in the docs about it, but does one of your upstream providers (like DNS routing) provide any of this info?

Happy to share my use case if you’d like.

Right now, we only give you the region the request came through (FLY_REGION header). We don’t have any quick way to do geo ip lookups, the licensing for most of those tools won’t let us include them in requests. There are probably free libraries for your runtime though! This one for Node looks pretty decent: https://github.com/geoip-lite/node-geoip

Thanks for the response! Maxmind is a little inaccurate for what I need but getting a good source of data is not easy.

@austincollinpena I have been looking into this too. I haven’t tried it, but one possible solution may be to proxy the request through a Cloudflare worker. Doing so shouldn’t add much to the latency as they run all over the world. It seems you then get access to all the location data you could want: city, country, continent etc, added by them:

See https://developers.cloudflare.com/workers/runtime-apis/request#incomingrequestcfproperties

You’re a life saver. Thank you Greg!

However I need to have a multitenant application and would need their subdomains for SaaS. I’ll look into that as an option for the future.

Unless you see a way around having TLS termination on their end?

You’re welcome.

Hmm … not sure. From what I can see, they provide SSL as part of their proxy and so you are then free to make whatever subrequest you need in the worker. Like on https://developers.cloudflare.com/workers/examples/bulk-origin-proxy it gives an example of using multiple origins. And so in theory you could look at the requested domain and pick the one to use. But … if they have a paid product for that, I’m guessing workers won’t let you bypass using that :frowning:

Doing custom domains with them is uber expensive.

How precise are you trying to get?

@greg For that to work I need to have all the connecting domains proxied through Cloudflare.

@kurt I’m only going to offer city level customization if I can get 95%+ for most cases. Providers like Akamai, Fastly, and others with DNS level data hit those numbers. However, you need to use them as your actual provider to get that data.

Are you ok with changing the application design to make separate calls to get the location? I built blip.runway7.net for that. Running a separate location echo API helps a bit if you’re willing to change your request flow.

If you want headers only without separate calls, and you have a lot of custom domains, I’d consider one Cloudfront distribution per customer and domain. The CF units are free, and it’s possible to create them off the API. And you’ll get the headers as well. And free SSL for each domain.

Thanks for the advice @sudhir.j, I think I’ll do that.