Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Blocking IP From All The Country With GeoIP ( VestaCP )
New on LowEndTalk? Please Register and read our Community Rules.

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

    Thanked by 1obh_ridwan
  • sirmbhesirmbhe Member
    edited March 2015

    Out of topic question : Why you want to block your own country?

  • If you're using CloudFlare, you can block countries there too.

    Thanked by 1obh_ridwan
  • @sirmbhe said:
    Out of topic question : Why you want to block your own country?

    I am a blogger and there is adsense, i want a visitor from spesific outside, just in US.

  • @obh_ridwan said:
    I am a blogger and there is adsense, i want a visitor from spesific outside, just in US.

    What's your blog site?

  • jarjar Patron Provider, Top Host, Veteran

    @Mark_R said:
    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 ;)

  • @Jar said:
    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.

  • MuServers said: If you're using CloudFlare, you can block countries there too.

    +1 with cloudflare, also you can use incapsula too. Btw thanks for the tutorial.

    Thanked by 1obh_ridwan
  • aglodekaglodek Member
    edited March 2015

    @obh_ridwan said:

    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)

  • adxnadxn Member, Host Rep

    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.

    @aglodek said:
    Wouldn't it be more efficient to do early on with iptables? (assuming you want to block by IP location, not language)

  • @adxn said:
    I want to forward my visitors from blocked country to an another page any idea how to do that?

    Yes you can. is your site wordpress based ?. you can use IQ block plugin they can redirect a another page or site.

  • adxnadxn Member, Host Rep

    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/

    Thanked by 1adxn
Sign In or Register to comment.