Region blocking

Rickster

EVGA Fanatic
Joined
Jul 31, 2012
Messages
23,076
Reaction score
5,335
Location
Joe'berg
Does anyone know how to block regions either via cPanel, a plugin or even the host

Basically we want to block every region except for ZA from accessing the website.


Please advise.

Thanks.
 
1) Install GeoIP and mod_geoip - https://grepitout.com/install-mod_geoip-cpanel-easyapache-4/

2) Create the folders :
Code:
/etc/apache2/conf.d/userdata/std/2_4/<username>/<domain>/"
/etc/apache2/conf.d/userdata/ssl/2_4/<username>/<domain>/"

3) In those folders create the file mod_geoip.conf

4) Put your geolocation restrictions in the mod_geoip.conf file
for example:
Code:
                <IfModule mod_geoip.c>
                  GeoIPEnable On
                  GeoIPDBFile /usr/share/GeoIP/GeoIPCity.dat
                  GeoIPScanProxyHeaders On
                  SetEnvIf GEOIP_COUNTRY_CODE ZA AllowCountry
                </IfModule>

                <Location />
                  Deny from all
                  Allow from env=AllowCountry
                </Location>

5) Restart httpd
 
Above solution might place more load on the server (also assumes you have access to the server, and not a shared hosting environment), and if it's a shared server (which it more than likely is) they'll hit you on resource usage.

You could move your DNS to Cloudflare and use them to block all countries except for SA.

If it's a Wordpress site, I suggest running Wordfence to help fend off attackers, and then perhaps use it's "Blocking" feature to block everything except ZA.
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X