Skip to content

Instantly share code, notes, and snippets.

@zabir-nabil
Created September 11, 2021 00:33
Show Gist options
  • Save zabir-nabil/30cd51665683708431918975e5c79ed5 to your computer and use it in GitHub Desktop.
Save zabir-nabil/30cd51665683708431918975e5c79ed5 to your computer and use it in GitHub Desktop.
Deploying free email server, web hosting panel with CyberPanel on subdomain, FastAPI with SSL, mongoDB transfer
Deploying free email server, web hosting panel with CyberPanel on subdomain
Summary:
Let's say we have a domain "test.com". We want to install an email server for our domain, we want it free.
First make sure the droplet has no app running on port 80, 443 (or nginx, apache websites).
Install CyberPanel,
on DO, https://marketplace.digitalocean.com/apps/cyberpanel
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
mail server:
RDNS is important: https://www.youtube.com/watch?v=8G93NVWkXZk&list=LL&index=4&t=761s
https://www.digitalocean.com/community/tutorials/iptables-essentials-common-firewall-rules-and-commands#service-mail
Deploying a simple recommendation rest api service using FastAPI
https://stackoverflow.com/questions/69138537/uvicorn-fastapi-python-run-both-http-and-https
Create a digitalocean droplet with public IP.
Make your domain point to digitalocean nameserver. Now, from digitalocean, create a domain with same setup.
Inside the DO domain, now you can add different records.
Add an A record, with api (subdomain) and point it to the new droplet public IP.
We can temporarily, run the app inside tmux in detached mode.
Now, we need to add SSL.
reference:
https://dev.to/knowbee/how-to-setup-secure-subdomains-using-nginx-and-certbot-on-a-vps-4m8h
https://dev.to/rajshirolkar/fastapi-over-https-for-development-on-windows-2p7d
sudo apt install -y certbot
sudo certbot certonly -d api.reee.uk
choose Spin up a temporary webserver (standalone) and continue, should have certificates.
Auto-renewal (test):
sudo systemctl status certbot.timer
sudo certbot renew --dry-run
Transfering MongoDB database from one server to another
Install MongoDB [ubuntu 20]:
https://linuxhint.com/install_mongodb_ubuntu_20_04/
sudo apt update
sudo apt upgrade
sudo apt install mongodb
sudo systemctl status mongodb
start:
sudo systemctl start mongodb
stop:
sudo systemctl stop mongodb
restart:
sudo systemctl restart mongodb
In old server,
mongodump --db DataBaseName
A dump folder will be created containing the database files.
In new server,
mongorestore --db DataBaseName /path/to/DataBaseName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment