Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
New Webmasters ask "How-To" questions here. This is where other fucking Webmasters help.

 
Thread Tools
Old 11-03-2017, 03:03 AM   #1
vintageadult
VPB Media
 
Industry Role:
Join Date: Jun 2015
Location: NL
Posts: 343
How to block certain countries by using cloudflare's free version?

How do you block some middle east country traffic while using cloudflare's free package?
__________________
Need a cheap adult web design and marketing service? Try us!
Vintage Adult Tube Stepfamily Taboo Clips
Vintage Adult Blog

JOIN VPB-CASH AFFILIATE PROGRAM AND EARN 50% ON SALES!
Our Skype ID: Vintagepornbay
We can sell our ad places and guest posts. Also help for all of your traffic needs.
vintageadult is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-03-2017, 04:35 AM   #2
magneto664
Confirmed User
 
magneto664's Avatar
 
Industry Role:
Join Date: Aug 2014
Location: Glasgow
Posts: 451
Quote:
Originally Posted by vintageadult View Post
How do you block some middle east country traffic while using cloudflare's free package?
Forbidden. Only Enterprise customers and enterprise zones are allowed to block a country

but you can try add a IP range for a country for example : IP Address Ranges by Country | IP2Location LITE

tnx.
__________________
magneto664 📧 gmail.com adult+seo+professional+seo+advice
adult backlinks 💘 My Fav: 👍chaturbate 👍 stripchat 👍 dateprofits 👍 datetronix 👍
\\ 📹 planetxxx.net 📹 onlycamsex.com 📹 camsdepot.com 📹 camsbell.com 📹 campapa.com 📹 escorts-kingdom.com 📹 camsholic.com
magneto664 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-03-2017, 06:55 AM   #3
faperoni
Registered User
 
faperoni's Avatar
 
Industry Role:
Join Date: Feb 2015
Location: Amsterdam
Posts: 39
No need for ip2location if you are using Cloudflare. Just enable the "IP Geolocation" option and you can get the visitors country like this:

$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];

Now lets say you want to block visitors from Kuwait you simply do:

if($country_code == 'KW'){
exit; //or redirect or whatever
}

Multiple countries:

$blocked_countries = array('KW','AE','IQ');
if (in_array($country_code, $blocked_countries)) {
exit;//or redirect whatever
}

CF guide:
support.cloudflare[.]com/hc/en-us/articles/200168236-What-does-Cloudflare-IP-Geolocation-do-

Country codes:
github[.]com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv

Let me know if you need help setting this up, good luck!
__________________
Faperoni and Cheese! Massage that sausage! ICQ: 712671126

Last edited by faperoni; 11-03-2017 at 07:00 AM.. Reason: typo
faperoni is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-07-2017, 08:45 AM   #4
vintageadult
VPB Media
 
Industry Role:
Join Date: Jun 2015
Location: NL
Posts: 343
Quote:
Originally Posted by faperoni View Post
No need for ip2location if you are using Cloudflare. Just enable the "IP Geolocation" option and you can get the visitors country like this:

$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];

Now lets say you want to block visitors from Kuwait you simply do:

if($country_code == 'KW'){
exit; //or redirect or whatever
}

Multiple countries:

$blocked_countries = array('KW','AE','IQ');
if (in_array($country_code, $blocked_countries)) {
exit;//or redirect whatever
}

CF guide:
support.cloudflare[.]com/hc/en-us/articles/200168236-What-does-Cloudflare-IP-Geolocation-do-

Country codes:
github[.]com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv

Let me know if you need help setting this up, good luck!
Hi thanks. Is that available on free plan?
And beside on that I have another problem with cloudflare: Whenever I adjust dns to cloudflare my wordpress site starts logging out me from backend. Every 10 or 20 seconds it keeps logging me out and asks for login again and also the website posts goes back to older times. I tried everthing: like purging cache , deleting other caching files plugins but it didnt fix this issue.
__________________
Need a cheap adult web design and marketing service? Try us!
Vintage Adult Tube Stepfamily Taboo Clips
Vintage Adult Blog

JOIN VPB-CASH AFFILIATE PROGRAM AND EARN 50% ON SALES!
Our Skype ID: Vintagepornbay
We can sell our ad places and guest posts. Also help for all of your traffic needs.
vintageadult is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-07-2017, 11:59 AM   #5
faperoni
Registered User
 
faperoni's Avatar
 
Industry Role:
Join Date: Feb 2015
Location: Amsterdam
Posts: 39
Yes that feature is available on the free plan:
Cloudflare -> Network -> IP Geolocation

Are you 100% sure that you are pointing cloudflare DNS to the right server? And do you have the same issues if you disable all CF features? (click the orange cloud icon on the right side of the dns entries, if the cloud icon is grey cloudflare will not cache or do anything with your traffic)
__________________
Faperoni and Cheese! Massage that sausage! ICQ: 712671126
faperoni is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-20-2017, 11:50 AM   #6
vintageadult
VPB Media
 
Industry Role:
Join Date: Jun 2015
Location: NL
Posts: 343
Quote:
Originally Posted by faperoni View Post
No need for ip2location if you are using Cloudflare. Just enable the "IP Geolocation" option and you can get the visitors country like this:

$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];

Now lets say you want to block visitors from Kuwait you simply do:

if($country_code == 'KW'){
exit; //or redirect or whatever
}

Multiple countries:

$blocked_countries = array('KW','AE','IQ');
if (in_array($country_code, $blocked_countries)) {
exit;//or redirect whatever
}

CF guide:
support.cloudflare[.]com/hc/en-us/articles/200168236-What-does-Cloudflare-IP-Geolocation-do-

Country codes:
github[.]com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv

Let me know if you need help setting this up, good luck!
Where should I add this code:
Code:
if($country_code == 'KW'){
    exit; //or redirect or whatever
}
to .htaccess or where?
Does it works on shared hosting?
__________________
Need a cheap adult web design and marketing service? Try us!
Vintage Adult Tube Stepfamily Taboo Clips
Vintage Adult Blog

JOIN VPB-CASH AFFILIATE PROGRAM AND EARN 50% ON SALES!
Our Skype ID: Vintagepornbay
We can sell our ad places and guest posts. Also help for all of your traffic needs.
vintageadult is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-21-2017, 03:01 PM   #7
faperoni
Registered User
 
faperoni's Avatar
 
Industry Role:
Join Date: Feb 2015
Location: Amsterdam
Posts: 39
Best would be a php page that is included on all your pages. I see you use wordpress (from your sig) you could add that code to the wp_config.php file. Make a backup first.

So enable the cloudflare "IP Geolocation" setting and then add the code below anywhere between the <?php here ?> tags

$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
if($country_code == 'KW'){
exit; //or redirect or whatever
}
__________________
Faperoni and Cheese! Massage that sausage! ICQ: 712671126
faperoni is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
cloudflares, block, free, east, middle, country, package, traffic, version, countries
Thread Tools




©2000-, AVN Media Network Inc



Powered by vBulletin
Copyright 2000- Jelsoft Enterprises Limited.