Have you already set the geoip_country variable? It is specified in the http block and indicates the path to the file - the GeoIP database. If it is already configured, you can use the $geoip_country_code and $geoip_country_code that return two and three letter country codes. Further, it will be convenient to use the map directive, in the same http block, in about the same way:
map $geoip_country_code $you_shall_not_pass { default yes; RU no; BY no; KZ no; }
In this variant, if the $geoip_country_code variable has the values RU , BY , KZ , then the $you_shall_not_pass variable will take the value no . In all other cases, yes .
Now, in the server block of the desired site, you can write the following restriction in a specific location :
if ($you_shall_not_pass = yes) { return 444; }
That is, if the $you_shall_not_pass variable is set to yes , that is, the code is strange does not belong to the allowed ones and the request should not pass, then ... it does not pass. How to change the configuration for the option if you need permission by default, and a ban for the listed countries, I think it is not necessary to explain.