All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
I wrote a shell script that turns spare VPS into a CDN node in one click
As title suggests. There are loads of scripts that install LAMP or LEMP stacks. There are loads of scripts that install VPNs. There are even loads of scripts that install mail servers. But automatically installing CDN seems pretty rare.
I have a bunch of spare VPS (I guess this applies to many LET users lol) located all over the world. Therefore, I decided to turn them into CDN nodes so that they can accelerate my websites. By sharing it, I hope that it can be helpful to other people.
Github link
https://github.com/Har-Kuun/OneClickCDN
Stars and forks are appreciated.
System requirement
- Ubuntu 20.04 LTS 64 bit, or Debian 10 (experimental)
- 1 IPv4
- At least 512 MB for running the CDN instance
- For the very first time, building the program from source requires about 1.5 GB RAM. You may add SWAP to your VPS for this step.
- Root access or sudo user
How to use
wget https://raw.githubusercontent.com/Har-Kuun/OneClickCDN/master/OneClickCDN.sh && sudo bash OneClickCDN.sh
Features of this script
- Build Traffic Server from source
- Add websites
- Manage SSL (provide certificates/key or automatically issue certificates with Let's Encrypt)
- Manage CDN websites, purge cache, view stats, change IP...
- Guided configuration
Why Traffic Server?
Many people favor Varnish or Nginx. Traffic Server is kind of old fashioned, but it still works great. It behaves decent in very high load. I tested a CDN node (1 E5 core, 1 GB RAM, 30 Mbps port) with loader.io using 2000 concurrent users sending 380000 requests continuously within 1 minute. The CDN node handled all of these successfully with average CPU load of only 40%. Check loader.io test result here https://bit.ly/32xD1nI
All suggestions, questions, and bug reports are highly appreciated. Thank you!
Comments
What does the management interface look like? What statistics are available to view? Is it possible to centrally manage all the nodes from a master server?
From his project website (all in Chinese), I see the following for "interface"
I don't often click on shell scripts to run them on servers, but if you did have a desktop environment installed, wouldn't it take a double click to launch?
Yes, it's just bunch of options to allow you to choose from, not actually an interface.
Here is a sample stats report.
This is possible if you install Traffic Control http://traffic-control-cdn.readthedocs.io/en/latest/index.html but it is not included in the script itself.
You'll have to run this in shell with sudo users. Double click won't work I think.
Huge script from China that needs sudo privilegies. I'll pass
Very small script and open source without any odd code, see yourself:
https://github.com/Har-Kuun/OneClickCDN/blob/master/OneClickCDN.sh
Based on your comments you can work for BBC TV.
@umi So I guess you hate Chinese people?
A quick scan of the script and it looks promising.
I love Chinese people and don't like backdoors, especially when private keys are involved.
I don’t see where you specify other servers to it into a cluster/network together. Am I missing something?
Ah you'll have to run the script on each server that you'd like to use, then use DNS round robin/failover to point your domain to these IPs.
Thanks. What about keeping content/data synced between all the servers?
There is no backdoor here though?
These are CDN nodes, so they don't really store data. They only cache data from the origin server, so I think there is no need to sync data between all these servers.
Thanks. So caching the data could then in theory be 200gb if for example your site was hosting iso or videos?
Well done on the script.
Good documentation on script in git will help on new comers and interested parties.
Yes, exactly.
Thank you for the suggestion!
looks awesome, thanks!
Is this work like cloud flare where the cdn sit between the origin and automatically cache static resource, or some thing like bunnycdn?
This is just installation script. ATS works like any other cache which is used by CF or bunny. Of cuz there'll be performance differences depending on what stack and how much optimization was made across their deployment.
For simple setup, this script will help for beginners. In production setup, that needs to tune properly.
Upon installation, this will work like cloudflare, where the CDN nodes sit between the origin and automatically cach static (and dynamic, if configured) resource.
wonder if there's a way to have it cache things in front of a Plex Server. I know people do this with CF but a lot of times end up getting banned. Probably be easy to do with Emby since it doesn't have to deal with the idiotic cloud authentication that Plex requires.
There's no caching going on in those setups, they're just proxying traffic through CF to get around network issues.
You could definitely setup your own proxy though, following basically the same steps as those CF guides - just adding in some iptables rules on the VM in the middle.
I don't really know the answer and can only speculate. If the Plex Server respond with a Cache Control: no-cache header (which it likely will), this CDN will not cache it; if not, and the CDN is configured to cache dynamic content (which indeed is by default) then it should be able to cache the content.
It's open source you can check it by yourself
I suggest an uninstall script.
Also in the readme put a description of the commands. After installing I can't get back to the menu configuration list. There's no mention of ANY commands in the README.
Thanks for the feedback. I'll update it tomorrow. Actually, running the script again will bring you to the menu.
This could be another beginning like CENTMINMOD if maintained it well. But CDN doesn't work alone, need a good cluster to work together with fair amount of control and monitoring.
This script is just a cache/reverse-proxy. Would be good to rename or extend to support bigger scale as a vision. Otherwise gonna mislead more people to compare with cloudflare, bunny and etc.