Disclaimer: Don’t use it to host video, theres nothing preventing you from doing so other than Cloudflare tos (2.8) but it’s better if you just use it for image storage.
Today we will use Cloudflare & GitLab to make the best “free” & fast CDN!
How do we do this you may ask, well simple. GitLab provides us with 10 GB repository limit, we can use this to host our original data via GitLab Pages, then we serve it via Cloudflare, and we set a page rule for our CDN, so it always hit the cached version!
According to Cloudflare, a CDN is a
A content delivery network (CDN) refers to a geographically distributed group of servers which work together to provide fast delivery of Internet content.
A properly configured CDN may also help protect websites against some common malicious attacks, such as Distributed Denial of Service (DDOS) attacks.
- Domain. (you can use a subdomain that is on Cloudflare.)
- GitLab account.
Create your GitLab account if you don’t have one, go make it right now.
Then create a repository with any name and the file
.gitlab-ci.yml and a folder named
Then fill the
1image: alpine:latest 2 3pages: 4 stage: deploy 5 script: 6 - echo 'Nothing to do...' 7 artifacts: 8 paths: 9 - public 10 expire_in: 1h20min 11 rules: 12 - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
And your content on the public folder. Either image HTML file, anything.
After you’ve done the steps above, GitLab should auto generate a website.
The next steps will be pretty straight forward. On GitLab, go to settings → pages; then click on new domain. Add your domain there, and add it to Cloudflare by following the instructions. Next for optimization and 99% cache hit, set this page rule for your CDN domain
After that you’re good to go!
Thank you for reading, have a great day!