How to install CDN system
Install on Ubuntu 20.04
sudo apt update
sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools
sudo apt install python3-venv
home/username/cdn
cd home/username/cdn
python3 -m venv cdn_app
source cdn_app/bin/activate
pip install wheel
, pip insall uwsgi flask
home/username/cdn
)pip install -r requirements.txt
sudo ufw allow 5000
config/config.yaml
(the discord callback should be set to https://yourdomain.net/callback)python run.py
(Any errors saying cannot find "module" cant be fixed by running pip install module
)your-server-ip:5000
and the site should be online, if so ctrl+c in the consolecdn.ini
and wsgi.py
out of the vps-only folderrun uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:site
deactivate
source.sql
and change line 46 and 47mysql -u username -p
source home/username/cdn/source.sql
Create a service
Create the service file using sudo nano /etc/systemd/system/cdn.service
Add the following text to the file, make sure to change directorys to match yours
[Unit]
Description=uWSGI instance to serve the CDN
After=network.target
[Service]
User=username
Group=www-data
WorkingDirectory=/home/username/cdn
Environment="PATH=/home/username/cdn/cdn_app/bin"
ExecStart=/home/username/cdn/cdn_app/bin/uwsgi --ini cdn.ini
[Install] WantedBy=multi-user.target
Start the service using sudo systemctl start cdn
Make sure the service started using sudo systemctl status cdn
, if should say Active: active
Allow the service to run automatically using sudo systemctl enable cdn
Allow Nginx to handle requests
sudo nano /etc/nginx/sites-available/cdn
server {
listen 80;
server_name your_domain www.your_domain;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/username/cdn/cdn_site.sock;
}
}
sudo ln -s /etc/nginx/sites-available/cdn /etc/nginx/sites-enabled
sudo unlink /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl restart nginx
sudo ufw allow 'Nginx Full
Getting a SSL
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your_domain -d www.your_domain