Easiest solution IMO if you’re already using CloudFlare, even the free version: you can filter out certain countries. Otherwise, there’s probably other alternatives, even open source ones. Good terms to search for with your cloud provider or self hosted software may be middlewares, firewalls, serverless, edge functions, etc.
Awesome, I’m looking for frameworks like this, thanks for sharing.