Hello I am @1Dot in this short tutorial, We will learn to boost and secure our flarum site with Cloudflare Free Plan with some basic configuration before we begin here are some of the stats.
Without Cloudflare
With Cloudflare without any Configuration
With Cloudflare and Configured for Flarum
Note : This are the stats of discussion containing images and youtube embed in first post.
So as you can see in the above stats this Configuration helped us to get A grade on GtMetrix easily, So let's begin and learn how you can also get A Grade at GtMetrix like us.
Step 1 : Cloudflare Account
Firstly, If you are not having a cloudflare account get a one from here, Just set up your website, you will need to change your name servers so that you can enjoy cloudflare's edge network benefits.
Step 2 : Basic Configuration
- Now I assume that you added your website in Cloudflare, and Now we are going to do some basic configuration.
- Go to Speed section and then Optimization Tab scroll down and You will see Auto Minify enable on all HTML CSS JS, scroll bit more you will see Brotli compression simply enable it.
In this Step : We reduced the size of CSS, JS, etc. in order to get faster load times and reduce bandwidth usage as cloudflare will deliver this resources from their ULTRA Edge Network and We enable brotoli in order to Speed up page load times for your visitor’s HTTPS traffic by applying Brotli compression.
Step 3 : Browser level Caching
Go to caching section then select configuration tab and scroll down and set browser caching TTL to 1 Month.
In this step : We did configuration to tell browser to deliver images and logos from cache don't hit our server again and again until 1 month.
Step 4 : Edge Caching ( The Most Important Step! )
Go to Page rule section and Click add a new rule and set url path as discuss.flarum.org/assets/*
make sure you change discuss.flarum.org to your flarum domain or subdomain.
Now Click Add a Setting and from the dropdown select Edge Cache TTL then It will ask for time, Set the time to a month and we are done.
It should look like this
In this step : We instructed Cloudflare to cache our static content not dynamic content in order to reduce bandwidth usage and faster load times for your ultra website.
Step 5 : Securing Website
Go to SSL/TLS Tab then select Edge Certificates scroll down and enable Always use HTTPS if not already enabled.
Scroll a bit You will see HTTP Strict Transport Security (HSTS) click Enable HSTS and set the configuration as the following.
- Firstly Click I Understand and then proceed to Next Step
- Simply Click Save.
Now Scroll a bit and set the below options as shown in image.
Step 6 : Securing Admin Panel
Flarum's Admin Panel is already secure and good, But to make it ultra good and extra secure We will only allow our IP address to access.
Go to Firewall tab and then Firewall Rules and Create a Firewall Rule name it anything you like, select URI, then in second dropdown select contains, then add value /admin
, Now Click And
Button near value and in second input field Select IP Source Address in first field and in second field select does not equal and in value add your IP.
Blocking Other Countries : Select OR
near second input value field and now select Country, then select does not equal the enter your country,
Now, If you will scroll a bit you will see then
means what action to do if this things matches so simply select block as we don't want to allow them to access our admin.
That's all Enjoy you secure and faster forum.
A Quick Note : Before you go anywhere to test what improved Load your website in your browser 1 to 2 times in order to allow cloudflare to cache content.