{"id":1155,"date":"2018-07-29T13:06:57","date_gmt":"2018-07-29T11:06:57","guid":{"rendered":"https:\/\/pleskext.configbox.com\/bloquear-pasises-bots-plesk\/"},"modified":"2021-03-27T16:09:43","modified_gmt":"2021-03-27T15:09:43","slug":"deny-country","status":"publish","type":"post","link":"https:\/\/pleskext.configbox.com\/en\/deny-country\/","title":{"rendered":"Deny-country (Country and bot blocker for Plesk)"},"content":{"rendered":"<p>[vc_row][vc_column][cms_heading text=&#8221;Extension Functions&#8221; font_weight=&#8221;&#8221;][vc_column_text css=&#8221;.vc_custom_1569419718971{margin-bottom: 26px !important;}&#8221;]This Plesk extension will allow you to:<strong> block access to web hosting<\/strong> (website) <strong>from those locations that you consider convenient<\/strong>.<\/p>\n<p>You can easily block:[\/vc_column_text][cms_list cms_list=&#8221;%5B%7B%22cms_list_item%22%3A%22Access%20from%20entire%20countries.%22%7D%2C%7B%22cms_list_item%22%3A%22Bots%20that%20track%20the%20websites%20automatically.%22%7D%2C%7B%22cms_list_item%22%3A%22Block%20access%20to%20certain%20files%20only.%22%7D%2C%7B%22cms_list_item%22%3A%22Make%20a%20backup%20of%20the%20.htaccess%20file%20and%20restore%20it%20automatically.%22%7D%5D&#8221;][vc_empty_space][vc_column_text css=&#8221;.vc_custom_1569572441395{margin-bottom: 26px !important;}&#8221;]This blocking action will allow you achieve greater security on your website while achieving lower traffic consumption.<\/p>\n<p>You will avoid receiving spam in the forms or comments of your blog from the countries you block.[\/vc_column_text][vc_row_inner content_placement=&#8221;middle&#8221;][vc_column_inner][cms_heading text=&#8221;Requirements&#8221; font_weight=&#8221;&#8221;][\/vc_column_inner][vc_column_inner][\/vc_column_inner][\/vc_row_inner][vc_column_text css=&#8221;.vc_custom_1569419820464{margin-bottom: 0px !important;}&#8221;]To run the extension on your Plesk control panel you will need:[\/vc_column_text][cms_list cms_list=&#8221;%5B%7B%22cms_list_item%22%3A%22That%20your%20servers%20runs%20under%20Linux%22%7D%2C%7B%22cms_list_item%22%3A%22That%20your%20Plesk%20version%20is%2017.8%20or%20higher.%22%7D%2C%7B%22cms_list_item%22%3A%22Install%20as%20sysadmin%20some%20linux%20modules%20(mod_geoip%20and%20maxmind%20database)%20as%20well%20as%20make%20changes%20to%20the%20log%20system.%22%7D%5D&#8221;][vc_empty_space][vc_column_text css=&#8221;.vc_custom_1570007157204{margin-bottom: 0px !important;}&#8221;]Here are the instructions so you can do it easily.[\/vc_column_text][vc_empty_space][cms_heading text=&#8221;Installation&#8221; text_decoration=&#8221;underline&#8221; font_weight=&#8221;&#8221;][vc_column_text css=&#8221;.vc_custom_1570006762183{margin-bottom: 0px !important;}&#8221;]Here are the steps you must follow to be able to operate the extension correctly. <span style=\"color: #ff0000;\"><strong>It is important that you run them before installing the extension from Plesk<\/strong><\/span>.<\/p>\n<p>Of course, as we told you, <strong>you must have SSH access to your server<\/strong>.[\/vc_column_text][vc_toggle title=&#8221;If you use CENTOS 6,7 or 8&#8243;]<strong>1 &#8211; INSTALL MOD_MAXMINBBD<\/strong><\/p>\n<p># yum install -y httpd-devel gcc GeoIP GeoIP-GeoLite-data GeoIP-devel libmaxminddb libmaxminddb-devel GeoIP-data geolite2-city<\/p>\n<p># cd \/tmp<\/p>\n<p># wget https:\/\/github.com\/maxmind\/mod_maxminddb\/releases\/download\/1.2.0\/mod_maxminddb-1.2.0.tar.gz (if link is down or version unavailable, check correct version and link at\u00a0 https:\/\/github.com\/maxmind\/mod_maxminddb\/releases)<br \/>\n# tar xvzf mod_maxminddb-1.2.0.tar.gz<br \/>\n# cd mod_maxminddb-1.2.0<br \/>\n# .\/configure<br \/>\n# make install<br \/>\n# vi \/etc\/httpd\/conf.d\/geoip.conf<\/p>\n<p>&lt;IfModule mod_maxminddb.c&gt;<br \/>\nMaxMindDBEnable On<br \/>\nMaxMindDBFile CITY_DB \/usr\/share\/GeoIP\/GeoLite2-City.mmdb<br \/>\nMaxMindDBEnv GEOIP_COUNTRY_CODE CITY_DB\/country\/iso_code<br \/>\nMaxMindDBEnv MM_COUNTRY_NAME CITY_DB\/country\/names\/en<br \/>\n&lt;\/IfModule&gt;<\/p>\n<p>Save changes<\/p>\n<p><strong>2 &#8211; MODIFY VIRTUALHOST LOG FORMAT<\/strong><\/p>\n<p>&#8211; Create an new apache configuration file to change log format :<br \/>\n\/etc\/httpd\/conf.d\/zzzz_deny_country_change_log_httpd.conf<\/p>\n<p>with this contents :<code><\/code><code><\/code><\/p>\n<p><code>LogFormat \"%a %v@@%p@@%h %l %u %t \\\"%r\\\" %&gt;s %O \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\" GEOIP_COUNTRY_CODE=%{GEOIP_COUNTRY_CODE}e\" plesklog<\/code><\/p>\n<p># service httpd configtest &amp;&amp; service httpd restart<\/p>\n<p><code><\/code><\/p>\n<p><strong>3 &#8211; CHECK THAT IT WORKS CORRECTLY<\/strong><\/p>\n<p><em># tail -f \/var\/www\/vhosts\/system\/domain.com\/logs\/access_log<\/em><\/p>\n<p><em># 216.xxx.xx.xxx &#8211; &#8211; [02\/Oct\/2019:08:39:07 +0200] &#8220;GET \/index.html HTTP\/1.1&#8221; 200 17902 &#8220;-&#8221; &#8220;Mozilla\/5.0 (compatible; DotBot\/1.1; http:\/\/www.opensiteexplorer.org\/dotbot, help@moz.com)&#8221; GEOIP_COUNTRY_CODE=US<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong>4 &#8211; ONCE DONE LOOK FOR &#8220;DENY-COUNTRY&#8221; EXTENSI\u00d3N IN PLESK AND INSTALL IT<\/strong><br \/>\n<em><br \/>\n<strong><span style=\"color: #ff0000;\">It is important that before installing it you have executed the instructions indicated in points 1 to 3<\/span> <\/strong>if you don&#8217;t do it it is possible it could not work properly.<\/em>[\/vc_toggle][vc_toggle title=&#8221;If you use DEBIAN or UBUNTU&#8221;]<strong>1 &#8211; INSTALL MOD_MAXMINBBD<\/strong><br \/>\nYou had to follow these steps:<\/p>\n<p># apt-get install geoip-bin geoip-database libmaxminddb-dev apache2-dev<\/p>\n<ul>\n<li>Sign up https:\/\/www.maxmind.com\/en\/geolite2\/signup<\/li>\n<li>Login\u00a0 https:\/\/www.maxmind.com\/en\/account\/login<\/li>\n<li>Click on &#8220;Download database&#8221; &gt; GeoLite2 City &gt; Download GZIP<\/li>\n<li>Unpack file and upload the GeoLite2-City.mmdb file to your server, in \/usr\/share\/GeoIP (you can use winscp)<\/li>\n<\/ul>\n<p># cd \/tmp<\/p>\n<p># wget https:\/\/github.com\/maxmind\/mod_maxminddb\/releases\/download\/1.2.0\/mod_maxminddb-1.2.0.tar.gz (if link is down or version unavailable, check correct version and link at\u00a0 https:\/\/github.com\/maxmind\/mod_maxminddb\/releases)<br \/>\n# tar xvzf mod_maxminddb-1.2.0.tar.gz<br \/>\n# cd mod_maxminddb-1.2.0<br \/>\n# .\/configure<br \/>\n# make install<\/p>\n<p># vi \/etc\/apache2\/mods-enabled\/geoip.conf<\/p>\n<p>&lt;IfModule mod_maxminddb.c&gt;<br \/>\nMaxMindDBEnable On<br \/>\nMaxMindDBFile CITY_DB \/usr\/share\/GeoIP\/GeoLite2-City.mmdb<br \/>\nMaxMindDBEnv GEOIP_COUNTRY_CODE CITY_DB\/country\/iso_code<br \/>\nMaxMindDBEnv MM_COUNTRY_NAME CITY_DB\/country\/names\/en<br \/>\n&lt;\/IfModule&gt;<\/p>\n<p>Save changes<\/p>\n<p><strong>2 &#8211; MODIFY VIRTUALHOST LOG FORMAT<\/strong><\/p>\n<p><em>&#8211; Create an new apache configuration file to change log format :<br \/>\n\/etc\/apache2\/conf-enabled\/zzzz_deny_country_change_log_httpd.conf<br \/>\n<\/em><\/p>\n<p>with this contents :<\/p>\n<p><code>LogFormat \"%a %v@@%p@@%h %l %u %t \\\"%r\\\" %&gt;s %O \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\" GEOIP_COUNTRY_CODE=%{GEOIP_COUNTRY_CODE}e\" plesklog<\/code><\/p>\n<p># apache2ctl configtest &amp;&amp; service apache2 restart<\/p>\n<p><code><\/code><\/p>\n<p><strong>3 &#8211; CHECK THAT IT WORKS CORRECTLY<\/strong><\/p>\n<p><em>\u00a0<\/em><span style=\"color: #808080;\"><em># tail -f \/var\/www\/vhosts\/system\/domain.com\/logs\/access_log<\/em><\/span><\/p>\n<p><span style=\"color: #808080;\"><em># 216.xxx.xx.xxx &#8211; &#8211; [02\/Oct\/2019:08:39:07 +0200] &#8220;GET \/index.html HTTP\/1.1&#8221; 200 17902 &#8220;-&#8221; &#8220;Mozilla\/5.0 (compatible; DotBot\/1.1; http:\/\/www.opensiteexplorer.org\/dotbot, help@moz.com)&#8221; GEOIP_COUNTRY_CODE=US<\/em><\/span><\/p>\n<p><strong>4 &#8211; ONCE DONE LOOK FOR &#8220;DENY-COUNTRY&#8221; EXTENSI\u00d3N IN PLESK AND INSTALL IT<\/strong><br \/>\n<em><br \/>\n<strong><span style=\"color: #ff0000;\"><br \/>\nIt is important that before installing it you have executed the instructions indicated in points 1 to 3<\/span> <\/strong>if you don&#8217;t do it it is possible it could not work properly.<\/em>[\/vc_toggle][\/vc_column][\/vc_row][vc_row][vc_column][vc_empty_space][cms_heading text=&#8221;Screen captures&#8221; font_weight=&#8221;&#8221;][vc_gallery interval=&#8221;3&#8243; images=&#8221;1159,1158,1162,1161,1160&#8243; img_size=&#8221;200&#215;100&#8243;][\/vc_column][\/vc_row]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This extension will allow you to block access to entire countries to any website or only to certain files. You can also prohibit access to certain bots.<\/p>\n","protected":false},"author":1,"featured_media":1156,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[102],"tags":[104],"_links":{"self":[{"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/posts\/1155"}],"collection":[{"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/comments?post=1155"}],"version-history":[{"count":24,"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/posts\/1155\/revisions"}],"predecessor-version":[{"id":1933,"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/posts\/1155\/revisions\/1933"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/media\/1156"}],"wp:attachment":[{"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/media?parent=1155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/categories?post=1155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pleskext.configbox.com\/en\/wp-json\/wp\/v2\/tags?post=1155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}