Why do I need CloudFlare?
I already pay for a business internet connection to my house that gets 105mbps down and 25mbps up. Instead of paying for a VPS monthly I decided to just use my home Unraid server to host my blog. The only problem with this solution is with web assets (more specifically images on my blog) can quickly eat up precious bandwidth. In order to solve this solution I decided to go with CloudFlare so I could get speed & security.
If you haven't heard of CloudFlare I highly recommend you check them out if you do any sort of web hosting. Their DNS is superior to any other service I have tried (and they also recently launched a client DNS server 22.214.171.124). The Free Plan comes with DDOS protection and a free easy-to-use CDN (Content-Delivery Network) which we will be using to speed up our asset delivery (images, JS, and CSS). I also use it to mask my IP address of my home server from guests that visit my website (they see CloudFlare's proxy server's IP address).
Usually CDNs can cost a lot of money and they require some sort of plugin or library on your website. Because CloudFlare is plugged into your website on the DNS level it is able to just redirect asset requests to their world-wide server network so the asset loads from the closest server to the client. This literally makes it just a flip of a switch in the web interface to get it working. Pretty awesome!
You will need to create an account at CloudFlare if you don't already have one. You then need to add your website if you haven't already. Once it is added click on your website and go to the DNS settings. From here browse to your website's DNS record (such as example.com or in this case skylar.tech) and make sure the orange cloud is ON:
This orange cloud is what switches on Cloudflare's proxying of your website so it can do the DDOS protection, CDN, and other features.
The CDN cache should be enabled by default now. You can fine-tune the settings under the Cache tab for the website. They also have a ton of other features I recommend checking out
One of the caveats of using CloudFlare is that now your domain is pointing to CloudFlare's servers when the orange cloud is enabled. This matters if you host game, voice, or other servers on ports that aren't 80 or 443. Some services such as MineCraft or Matrix servers allow you to set a SRV DNS record that can point to the real IP address for that service.
You can also get around this issue by adding a sub-domain DNS record such as
server.example.com or something like that. Then just use that for any other services you host under that domain. The downside of this approach is then someone can get the real IP address of your server by just checking what DNS records exist that aren't CloudFlare servers. Because of this it really just depends on what you are trying to accomplish.
How much bandwidth have I saved?
Honestly not that much. My blog has very few posts right now and most of them do not have many images. Most of my content delivered is JSON straight from my Blog's server. Anyways, here are the results (you can find this graph for your own website under the bandwidth tab):
As I start customizing the site and adding more images to my blog posts the website should handle it perfectly. My page load times (tested with Pingdom) are right around 1.8 seconds:
And that is it. If you have any questions or feedback feel free to leave it below.