ElkArte Community

Project Support => Support => Topic started by: txcas on May 17, 2016, 09:45:38 am

Title: Can I block a country?
Post by: txcas on May 17, 2016, 09:45:38 am
Do we have an add-on that would allow me to block traffic from specific countries?  With all the anti-spam features on, email registration verification, Bad Behavior, etc., I still get spammers from China.
Title: Re: Can I block a country?
Post by: emanuele on May 17, 2016, 10:19:20 am
There is not really any good way to reliably block a country.
The only way is to block ranges of IP addresses that likely belong to a certain country. But I wouldn't do that from PHP, at least from htaccess or even better with some Apache module, for example with the old mod_geoip (https://linuxconfig.org/redirect-or-block-traffic-based-on-geographical-location-apache-geoip-mod) (now replaced by MaxMind DB (http://maxmind.github.io/mod_maxminddb/) as far as I understood).
Title: Re: Can I block a country?
Post by: txcas on May 17, 2016, 12:15:41 pm
Thanks.
Title: Re: Can I block a country?
Post by: Spuds on May 17, 2016, 02:18:59 pm
If you have your own VPS then you can do it with the max-mind geoIP database ... this is updated monthly (generally).

Both Apache and Nginx have geoip modules that work with the max mind DB.  So when user visits, the IP location is determined and you can block or allow it on a per country basis.   Of course since IP's are dynamic you run a small chance of blocking the wrong folks until the DB is updated again.

If you do any of that be sure to have a cron job that refreshes those DB files one a month or so.
Title: Re: Can I block a country?
Post by: badmonkey on May 17, 2016, 05:01:31 pm
^^ what they said.  Or if you have proper server control, you can install ConfigServer firewall.  It allows nation blocking as a feature.  CSF has several other really nice features as well.  Good luck!

http://www.configserver.com/cp/csf.html
Title: Re: Can I block a country?
Post by: Spuds on May 17, 2016, 06:44:53 pm
Quote from: badmonkey – ConfigServer firewall.  It allows nation blocking as a feature.  CSF has several other really nice features as well.  Good luck!

http://www.configserver.com/cp/csf.html
Cool .. had not seen that one before, may have to give it a whirl as it looks very complete.  I've always used a combo of UFW + Fail2Ban with just a handful of open ports.
Title: Re: Can I block a country?
Post by: meetdilip on May 18, 2016, 04:05:20 am
Virtualmin has CSF by default
Title: Re: Can I block a country?
Post by: hartiberlin on January 20, 2018, 08:50:48 pm
Does anybody know a good hoster that supports this CSF together with CPanel WHM and is not too expensive..So not more than 10 to 20 USD per month for hosting ?
I am mostly interested to block users who make too much traffic in the forum and try to download the whole forum..
How can these be blocked ?
Or is there a simple Website firewall available for Elkarte that can do this ?
Title: Re: Can I block a country?
Post by: ahrasis on January 21, 2018, 12:13:57 am
Is no point of blocking a country. Limiting access time should be fine though.