All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Blocking IP From All The Country With GeoIP ( VestaCP )
First, I want block my country Indonesia to access my site, my site is wordpress based, and i use a plugin iq-block-country, i don't know why that plugin isn't working and ruin my site.
I use VestaCp for my webserver just install a module geoip with this command
$ sudo apt-get install libapache2-mod-geoip
And then edit apache2.conf in /home/admin/conf/web/apache2.conf
$ sudo nano /home/admin/conf/web/apache2.conf
Add the code below into our config :
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
SetEnvIf GEOIP_COUNTRY_CODE ID BlockCountry
Before the line
IncludeOptional /home/admin/conf/web/apache2.yourwebsite.com.conf*
ID is code the coutry of Indonesia, you can change or add ID in SetEnvIf GEOIP_COUNTRY_CODE ID BlockCountry with another.
Save it and then edit .htacces in your public_html directory , fill with the following code :
Deny from env=BlockCountry
And then save and restart the apache service.
$ sudo service httpd restart
Done. Is for ubuntu only, in the next post i will post if the operating system is centos .
Thank you, i think this is just beginner tutorial. i am sorry if This tutorial is not very useful for you.
Best Regards.
Comments
thank you
Out of topic question : Why you want to block your own country?
If you're using CloudFlare, you can block countries there too.
I am a blogger and there is adsense, i want a visitor from spesific outside, just in US.
What's your blog site?
Don't answer that question, or send the answer via private message, unless you're ready for the incoming DDOS
yeah definitly pm me about it.
+1 with cloudflare, also you can use incapsula too. Btw thanks for the tutorial.
Interesting. Do you know if this is based on referrer agent OS/browser language or IP location?
Wouldn't it be more efficient to do early on with iptables? (assuming you want to block by IP location, not language)
I want to forward my visitors from blocked country to an another page any idea how to do that?
Thank you for your additional. yes actually good one if you are blocking with iptables.
Yes you can. is your site wordpress based ?. you can use IQ block plugin they can redirect a another page or site.
Sorry it is not wordpress! any idea what to do?
You can use cloudflare for country blocking and make custom 403 page and redirect it into another site. may be this site can help your problem
http://nginxlibrary.com/using-cloudflare-for-country-blocking/