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_MAXMINBBD
    You had to follow these steps:

    # yum install -y httpd-devel gcc GeoIP GeoIP-GeoLite-data GeoIP-devel libmaxminddb libmaxminddb-devel GeoIP-data geolite2-city
    # cd /tmp
    # wget https://github.com/maxmind/mod_maxminddb/releases/download/1.1.0/mod_maxminddb-1.1.0.tar.gz
    # tar xvzf mod_maxminddb-1.1.0.tar.gz
    # cd mod_maxminddb-1.1.0
    # ./configure
    # make install
    # vi /etc/httpd/conf.d/geoip.conf

    <IfModule mod_maxminddb.c>
    MaxMindDBEnable On
    MaxMindDBFile CITY_DB /usr/share/GeoIP/GeoLite2-City.mmdb
    MaxMindDBEnv GEOIP_COUNTRY_CODE CITY_DB/country/iso_code
    MaxMindDBEnv MM_COUNTRY_NAME CITY_DB/country/names/en
    </IfModule>

    Save change


  2. MODIFY VIRTUALHOST LOG FORMAT

    You have 2 option to do it :

    Option 1 :
    - Create an new apache configuration file to change log format :
    /etc/httpd/conf.d/zzzz_deny_country_change_log_httpd.conf

    with this contents :

    LogFormat "%a %v@@%p@@%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" GEOIP_COUNTRY_CODE=%{GEOIP_COUNTRY_CODE}e" plesklog

    #service httpd configtest && service httpd restart

    Option 2 :
    # 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


    #service httpd configtest && service httpd restart

  3. 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

  4. 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