Deny-country (Country and bot blocker for Plesk)

Extension Functions

This Plesk extension will allow you to: block access to web hosting (website) from those locations that you consider convenient.

You can easily block:

  • Access from entire countries.
  • Bots that track the websites automatically.
  • Block access to certain files only.
  • Make a backup of the .htaccess file and restore it automatically.

This blocking action will allow you achieve greater security on your website while achieving lower traffic consumption.

You will avoid receiving spam in the forms or comments of your blog from the countries you block.

Requirements

To run the extension on your Plesk control panel you will need:

  • That your servers runs under Linux
  • That your Plesk version is 17.8 or higher.
  • Install as sysadmin some linux modules (mod_geoip and maxmind database) as well as make changes to the log system.

Here are the instructions so you can do it easily.

Installation

Here are the steps you must follow to be able to operate the extension correctly. It is important that you run them before installing the extension from Plesk.

Of course, as we told you, you must have SSH access to your server.

  1. INSTALL MOD_GEOIP
    To do it you must type the instruction:

    yum install mod_geoip

  2. UPDATE THE CENTOS COUNTRY DATA BASE
    To do it run the following instructions:

    # wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip


    # wget https://github.com/sherpya/geolite2legacy/archive/master.zip

    # yum install unzip python-pip

    # pip install ipaddr

    # unzip master.zip


    # cd geolite2legacy-master


    # ./geolite2legacy.py -i ../GeoLite2-Country-CSV.zip -f geoname2fips.csv -o /usr/share/GeoIP
    /GeoIP.dat


  3. MODIFY VIRTUALHOST LOG FORMAT

    # cp /usr/local/psa/admin/conf/templates/default/server.php/usr/local/psa/admin/conf/templates/custom/server.php

    # replace '"" plesklog' '" GEOIP_COUNTRY_CODE=%{GEOIP_COUNTRY_CODE}e" plesklog' -- /usr/local/psa/admin/conf/templates/custom/server.php

    # plesk sbin httpdmng --reconfigure-server


  4. CHECK THAT IT WORKS CORRECTLY

    # tail -f /var/www/vhosts/system/domain.com/logs/access_log

    # 216.xxx.xx.xxx - - [02/Oct/2019:08:39:07 +0200] "GET /index.html HTTP/1.1" 200 17902 "-" "Mozilla/5.0 (compatible; DotBot/1.1; http://www.opensiteexplorer.org/dotbot, help@moz.com)" GEOIP_COUNTRY_CODE=US

  5. ONCE DONE LOOK FOR "DENY-COUNTRY" EXTENSIÓN IN PLESK AND INSTALL IT
    It is important that before installing it you have executed the instructions indicated in points 1 to 3
    if you don't do it it is possible it could not work properly.

Screen captures

Leave A Comment

Create your account