Answer the question
In order to leave comments, you need to log in
Blocking users on the site by location?
Hi all.
I was given the following task:
It is necessary that there is no access to the site from one specific country.
For example from India.
You can block by ip mask, but this is somehow not ice.
You can add geolocation.
Who else has ideas?
Answer the question
In order to leave comments, you need to log in
I’ll tell you using nginx as an example, in any case, if you don’t use it yet, it’s time to start)
there is a ngx_http_geo_module module, ext is enabled by default (not to be confused with ngx_http_geoip_module). This module can check the visitor's IP with masks and assign the country code to the variable. For its operation, you need a free GeoIP City Free database, it is downloaded from the maxmind site in csv format and the perl script that comes with the nginx sources is converted to the nginx config format - say geo.conf
Add to the config:
geo $country {
include geo.conf;
}
if ($country = "cn") {
return 403;
}
this example denies access from china
I used geoip on the site. And I gave different countries a site in the right language + additional features.
What does "no ice" mean? There are only three options, and blocking by ip is the most accurate.
You can also use the name of the first level domain (deny from .in) or the language in the browser. But this is just not ice at all. Surely in India, all providers on .com and .net sit, and the language of most is English.
And, well, you can still ask the visitor: “And you, for an hour, will you not be from India?” :)
www.maxmind.com/ - database by ip.
Yes, and Google will help you with the request geoip
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question