I want to block a city with cf.city in workers

In an earlier post “Block City” (Block city), Judge said:

“If you have the Business Plan on the zone you’d protect, you could use a Worker script that checks the cf.city object which uses the MaxMind GeoIP data source for IP city geolocation. This data isn’t currently provided to lower tiered zones.”

I have not used workers. Could someone provide an example of blocking Hendersonville, NC with a couple screenshots?

I wouldn’t really recommend using this data to block people, but if you really want to try it, you can take a look at Worker Examples for inspiration:

https://developers.cloudflare.com/workers/examples/block-on-tls

You can modify this to look at the request.cf.city instead of request.cf.tlsVersion

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.