I was looking at what Cloudflare could do for my web site. A colleague pointed out that they have a free usage tier which supplies a web application firewall and some anti-bot measures. I checked it out and immedaitely signed up!
What Cloudflare is supplying at no cost (for personal web sites like mine) is amazing. It’s not just a world-class dns service. That would already be amazing. Run dnscheker.org against drjohnstechtalk.com and you will see several different IPs mentioned around the world- just like the big guns! I also get for free some level of mitigation against dns-based attackes.
Web site protections
I don’t fully understand their products so I don’t know what level of protections I am getting in the free tier, but there are at least some! They say they’ve blocked 10 requests in the last few days
Web usage stats
I have to admin using raw linux tools against my apache access file hasn’t bee n the most illuminating until now. Now that I use Cloudflare I get a nice visual presentation showing where (which country) my visitors came from, where the bots come from, how much data was transmitted.
Certificate for HTTPS
Cloudflare automatically takes care of the web site certificate. I had to do nothing at all. So now I can forget my call out to LetsEncrypt. I wonder if GoDaddy is still charging $69 annually for their certificates.
Yeah my web site just feels faster now since the switch. It just does. And Cloudflare stats say that about 30% of the content has been served from their cache – all with zero setup effort on my part! I also believe they use certain tcp acceleration techniques to speed things up.
And Cloudflare caches some of my objects to boost performance. Considering that I pay for data transfer at Amazon AWS, it’s a fair question to ask if this caching could even be saving me money? I investigated this and found that I get billed maybe $ .02 per GByte, and in a busy month I might use .8 GB or so, so $ .02 per month. So I might occasionally save a penny or so – nothing substantial though!
Even with this free tier you get some geoDNS functionality for free, namely, visitors from around the world will see an IP address which is geographically close to where they are, bossting their performance when using your site. Stop to think about that. That’s a whole lot of infrastructure sophistication that they’re just giving you for free!
Why are they giving this much away?
I think they have the noble aim of improving the security posture of the Internet writ large. Much as letsencrypt greatly accelerated the adoptipon of web page encyrption (https) by making certificates free, Cloudflare hopes to accelerate the adoption of basic security measures for every web site, thereby lifting the security posture of the Internet as a whole. Count me as a booster!
What’s their business model. How will they ever make money?
Well, you’re only supposed to use the free tier for a personal web site, for one. My web sites don’t really have any usage and do not display ads so I think I qualify.
More importantly, the free security protections and acceleration are a kind of teaser and the path to upgrading to profesisonal tier is very visibly marked. So they’re not 100% altruistic.
Why I dislike GoDaddy
Let’s contrast this with offerings from GoDaddy. GoDaddy squeezes cents out of you at every turn. They make it somewhat mysterious what you are actually paying for so they’re counting on fear of screwing up (FOSU, to coin a term). After all, except for the small hit to your wallet, getting that upgraded tier – whois cloaking, anyone? – might be what you need. Who knows. Won’t hurt, right? But I get really tired of it. Amazon AWS is perhaps middle tier in this regards. They do have a free tier virtual server which I used initially. But it really doesn’t work except as a toy. My very modest web site overwhlemed it on too many occasions. So, basically useless. Everything else: you pay for it. But somehow they’re not shaking the pennies out of you at every turn unlike GoDaddy. And AWS even shows you how to optimize your spend.
How I converted my live site to Cloudflare
After signing up for Cloudflare I began to enter my dns domains, e.g., drjohnstechtalk.com, johnstechtalk.com, plsu a few others. They explained how at GoDaddy I had to update the nameserver records for these doamins, which I did. Then Cloudflare has to verify these updates. Then my web sites basically stopped working. So I had to switch the encryption mode to full. This mode encrypts the back-end data to my web server, but it accepts a self-signed certificate, no matter if it’s expired or not and no matter who issued it. That is all good because you still get the encrypted channel to your content server.
Then it began to work!
Restoring original visitor IPs to my apache web server logs
Very important to know frmo a technical standpoint that Cloudflare acts as a reverse proxy to your “content server.” Knowing this, you will also know that your content server’s apache logs get kind of boring because they will only show the Cloudflare IPs. But Cloudflare has a way to fix that so you can see the original IPs, not the Cloudlfare IPs in your apache logs.
Locking down your virtual server
If Internet users can still access the web server of your virtual server directly (bypassing Cloudflare), your security posture is only somewhat improved. To go further you need to use a local firewall. I debated whether to use AWS Network Security Groups or iptables on my centos virtual server. I went with iptables.
I lossely followed this developer article. Did I mention that Cloudflare has an extensive developer community? https://developers.cloudflare.com/fundamentals/get-started/setup/allow-cloudflare-ip-addresses/
Actually I had to install iptables first because I hadn’t been using it. So my little iptables script I created goes like this.
#!/bin/bash # from https://developers.cloudflare.com/fundamentals/get-started/setup/allow-cloudflare-ip-addresses/ # For IPv4 addresses curl -s https://www.cloudflare.com/ips-v4|while read ip; do echo adding $ip to iptables restrictions iptables -I INPUT -p tcp -m multiport --dports http,https -s $ip -j ACCEPT done ip=127.0.0.1 iptables -I INPUT -p tcp -m multiport --dports http,https -s $ip -j ACCEPT # maybe needed it just once?? #iptables -A INPUT -p tcp -m multiport --dports http,https -j DROP # list all rules iptables -S
I believe I just need to run it the one time, not, e.g., after every boot. We’ll soon see. The output looks like this:
-P INPUT ACCEPT -P FORWARD ACCEPT -P OUTPUT ACCEPT -A INPUT -s 127.0.0.1/32 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 22.214.171.124/13 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 126.96.36.199/14 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 188.8.131.52/13 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 184.108.40.206/15 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 220.127.116.11/17 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 18.104.22.168/22 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 22.214.171.124/20 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 126.96.36.199/20 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 188.8.131.52/18 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 184.108.40.206/18 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 220.127.116.11/22 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 18.104.22.168/22 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 22.214.171.124/22 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -s 126.96.36.199/20 -p tcp -m multiport --dports 80,443 -j ACCEPT -A INPUT -p tcp -m multiport --dports 80,443 -j DROP
Note that this still leaves ssh open, but that’s ok since it is locked down via Network Security Group rules. No urgent need to change those.
Then I made sure that direct access to my content server freezes, which it does, and that access through the official DNS channels which use Cloudflare still works, which it did. So… all good. The setup was not hard at all. But since I have several hosted web sites for the iptables to make any sense I had to be sure to migrate all my hosted sites over to Cloudflare.
I was dreading migrating my other zones (dns domains) over to Cloudflare. Still being in the GoDaddy mindframe I figured, sure, Cloudflare will permit me one zone for free, but then charge me for a second one.
So I plunged ahead. johnstechtalk.com. No charge!
And a third one: vmanswer.com. Also no charge!
And a fourth, and a fifth and a sixth.
I thought perhaps five will be the threshold. But it wasn’t. I only have six “zones” as Cloudflare now calls them. But they are all in my account and all free. Big relief. This is like the anti-GoDaddy.
Making DNS changes is quite fast. The changes are propagated within a minute or two.
Everything you can do in the GUI you can do through the api. I had previously created and shared some model python api scripts.
As if all the above weren’t already enough, I see Cloudflare also gives my web site accessibility via ipv6:
$ dig +short aaaa drjohnstechtalk.com
I guess it’s accessible through ipv6 but I haven’t quite proven that yet.
I originally forgot that I had set up mail forwarding on GoDaddy. It was one of the few free things you could get. I think they switched native Outlook or something so my mail forwarding wasn’t working. On a lark I checked if Cloudflare has complementary mail forwarding for my domains. And they do! So that’s cool – another free service I will use.
Sending mail FROM this Cloudflare domain using your Gmail account
This is more tricky than simple mail forwarding. But I think I’ve got it working now. You use Gmail’s own server (smtp.gmail.com) as your relay. You also need to set up an app password for Gmail. Even though you need to specify a device such as Windows, it seems once enabled, you can send from this new account from any of your devices. I’ve found that you also need to update your TXT record (see link below) with an expanded SPF information:
v=spf1 include:_spf.google.com include:_spf.mx.cloudflare.net ~all
In words it means the Google and Cloudflare sending servers are authorized to sends emails with this domain in the sender field, mail from elsewhere will be marked.
Even after all that I wasn’t seeing my sent message at work where Microsoft 365 is in use. It landed in the Junk folder! Why? The sending email “appears similar to someone who previously sent you email, but may not be that person.” Since I am a former mail admin I am sympathetic to what they’re trying to do – help hapless users avoid phishing; because it’s true – the characters in my test email did bear similarities to my regular email. My regular email is first_name.last_name @ gmail.com, while mail from this domain was first_name @ last_name + s .com Mail sent to a fellow Gmail user suffered no such fate however. Different providers, different approaches. So I can accept that. Once it’s set up you get a drop-down menu of sending addresses every time you compose a new message! The detailed instructions are at the Cloudflare community site.
Cost savings using Cloudflare
Suppose like me you only use GoDaddy as your reistrar and get all your other services in some other way. Well, Cloudflare began to pitch me on transferring my domanis to them. I thought, Aha, this is the moment they will make money off me. So I read their pitch. Their offer is to bill me for the charges they incur from ICANN or wherever, i.e., pass-through charges without any additional middleman overhead. It’s like, what? So let’s say at GoDaddy I pay $22 per year per domain. Well with Cloudflare I’d be paying something like $10 per year. For one domain I wouldn’t bother, but since I have more than five, I will be bothering and gladly leaving GoDaddy in the dust. I have just transferred the first two domains. GoDaddy seems to drag out the process as long as possible. I found I could expedite it by approving the transfer in the GoDaddy portal. Then Cloudflare had them within 30 minutes. It’s not super-easy to do a transfer, but also not impossble.
In typical GoDaddy style, executing a domain transfer to another registrar seems essentially impossible if you use their latest Domain portfolio app. Fortunately i eventually noticed the option to switch from “beta” to the old Domain manager, which still has the option and looks a bit more like their documentation. I’ve generated auth codes and unlocked, etc. And I even see the correct domain status (ok as opposed to client transfer prohibited) when I do a whois, but now Cloudflare, which is usually so quick to execute, seems to be lagging in recognizing that the domains have been unlocked and suggests to check back in some hours. Weird. The solution here was to provide my credit card info. Even 12 hours later I was having this trouble where it said none of my domains were eligible for transfer. As soon as I provided my payment information, it recognized two of my domains as eligible for transfer.
A plug for GoDaddy
As my favorite sport seems to be bashing GoDaddy I wanted to balance that out and say a few kind words about them. Someone in my houisehold just started a job with a startup who uses GoDaddy. It provides desktop Outlook Email, MS Teams, Sharepoint, helps with consulting, etc. And on day one this person was up and running. So if you use their services, they definitely offer value. My issue is that I tried to restrict my usage to just one service – domain registrar – and they pushed me to use it more extensively, which I resisted. But for a small business which needs those thnigs, it’s fine.
How many domains are you sharing your IP with?
The thnig with Cloudflare is that they assign you to a couple of their IP addresses, often beginning with either 172.67 or 104…. . Now did you ever wonder with how many other web sites you’re sharing those IPs? If not, you should! I found a tool that provides the answer: https://dnslytics.com/ So for this free tier they seem to keep the number around 500 unique domains per IP! Yes that’s a lot, but I’d only be concerned if there was evidence of service degradation, which so far I have not seen. What’s nice about the dnsyltics site is that it lists a few of the domains – far from all of them, but at least it’s 20 or 30 – associated with a given IP. That can be helpful during truobleshooting.
What Cloudflare provides for protective and performance services represents a huge forward advance in the state of the art. They do not niggle you for extra charges (entice is more the word here) for Fear of Screwing Up.
All in all, I am amazed, and I am something of an insider – a professional user of such services. So I heartily endorse using Cloudflare for all personal web servers. I have not been sponsored or even in contact with Cloudflare, by the way!
References and related
Cloudlfare tip: Restoring original visitor IPs to your apache web server.
Locking your virtual server down to just Cloudflare IPs: https://developers.cloudflare.com/fundamentals/get-started/setup/allow-cloudflare-ip-addresses/
Turn an IP addres into a list of associated domain names: https://dnslytics.com/