- You have a DigitalOcean droplet (Ubuntu 16.04)
- You have a domain with an A name record pointed at the droplet HINT - whenever possible I point the nameservers at digital ocean's nameservers.
Login to the servers
ssh -l root <your IP address>
Create a new sudo-enabled user
adduser <new username>
usermod -aG sudo <new username>
Exit and login with new user
exit
ssh -l <new username> <your IP address>
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get install python-certbot-nginx
sudo nano /etc/nginx/sites-available/default
Copy in the following, but leave all of the 'Managed by Certbot' lines:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server_name example.com www.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; #for websockets
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
#try_files $uri $uri/ =404;
}
Then test the setup, and restart nginx if successful
sudo nginx -t
sudo systemctl reload nginx
sudo ufw enable
sudo ufw status
sudo ufw app list
sudo ufw allow 'Nginx Full'
sudo ufw allow OpenSSH
sudo ufw status
should see
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx Full ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
sudo certbot --nginx -d example.com -d www.example.com
Exit and run
sudo nginx -t
sudo systemctl reload nginx
sudo crontab -e
enter the following
15 3 * * * /usr/bin/certbot renew --quiet
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo nano /etc/systemd/system/mongodb.service
Paste the following into the file
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
Then run the server
sudo systemctl start mongodb
sudo systemctl status mongodb
sudo systemctl enable mongodb
mongo
> use admin
> db.createUser(
{
user: "myUserAdmin",
pwd: "abc123",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
> quit()
mongo -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"
use myNewDatabase
db.createUser(
{
user: "myTester",
pwd: "xyz123",
roles: [ { role: "readWrite", db: "myNewDatabase" } ]
}
)
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y build-essential nodejs
sudo npm install -g forever