{"id":1154,"date":"2021-08-21T15:06:00","date_gmt":"2021-08-21T07:06:00","guid":{"rendered":"https:\/\/blog.wallaceho.com\/?p=1154"},"modified":"2021-08-21T15:11:22","modified_gmt":"2021-08-21T07:11:22","slug":"how-to-block-traffic-from-specific-countries-using-cloudflare","status":"publish","type":"post","link":"https:\/\/blog.wallaceho.com\/?p=1154","title":{"rendered":"How to block traffic from specific countries using CloudFlare"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If for any reason you want to block visitors from any country, the solution is extremely simple!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, enable the IP Geolocation in CloudFlare<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/images.ctfassets.net\/slt3lc6tev37\/7t7tvXvSPk3cHCz7D7rY6N\/e119dedc0dabc6c842032d7f0935dba5\/ip_geolocation.png\" alt=\"IP Geolocation card in Network app, Cloudflare dashboard.\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And then everything can be done from .htaccess file, via apache server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Block countries - IP Geolocation\n&lt;IfModule mod_rewrite.c&gt;\nRewriteEngine On\nRewriteCond %{HTTP:CF-IPCountry} ^(CN|IR|PK|TH|BD)$\nRewriteRule ^ - &#91;F,L]\n&lt;\/IfModule&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The country code list can be find from the below link:<br><a href=\"http:\/\/www.ip2country.net\/ip2country\/country_code.html\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/www.ip2country.net\/ip2country\/country_<\/a><a rel=\"noreferrer noopener\" href=\"http:\/\/www.ip2country.net\/ip2country\/country_code.html\" target=\"_blank\">code.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If for any reason you want to block visitors from any country, the solution is extremely simple! First, enable the IP Geolocation in CloudFlare And then everything can be done from .htaccess file, via apache server: The country code list &hellip; <a href=\"https:\/\/blog.wallaceho.com\/?p=1154\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1154","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/posts\/1154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1154"}],"version-history":[{"count":5,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/posts\/1154\/revisions"}],"predecessor-version":[{"id":1160,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/posts\/1154\/revisions\/1160"}],"wp:attachment":[{"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}