Setup -
# Install
sudo apt-get install nginx
# Enable
sudo ufw allow 'Nginx HTTP'
# Status
systemctl status nginx
Config -
server {
server_name www.site.com site.com;
listen *:80;
# Static
root /var/www;
# Dynamic
location / {
proxy_pass http://127.0.0.1:8000;
}
# Route
location /api/ {
proxy_pass http://127.0.0.1:3002;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
# Subdomain
server {
server_name api.site.com;
location / {
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:3000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
rewrite ^/api/?(.*) /$1 break;
}
}Blocks -
# Create block
touch /etc/nginx/sites-available/example.com
# Link
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
# Restart
sudo systemctl restart nginxDelete
certbot delete# create screen
screen -S <name>
# exit screen
CTRL + A => D
# resume screen
screen -r <sid>
# kill screen
CTRL + D
# screen list
screen -lsIf you can't access the drive, execute the following command:
sudo ntfsfix /dev/sdXY
where XY is the partition
e.g sda2 or sdb1
Then, mount with:
sudo mount -o rw /dev/sdXY
GPG Tool
sudo apt-get install gnupgFile encryption
gpg -c filenameFile decryption
gpg filename.gpg- Install
npm i -g pm2- Start
pm2 start app.js --name my-api- Cluster mode
# Start maximum processes with LB depending on available CPUs
pm2 start app.js -i 0
# Scales app up by 3 workers
pm2 scale app +3
# Scales app up or down to 2 workers total
pm2 scale app 2 - List
# Display all processes status pm2 jlist # Print process list in raw JSON pm2 prettylist # Print process list in beautified JSON
pm2 list
# Display all informations about a specific process
pm2 describe 0
# Monitor all processes
pm2 monit - Logs
# Display all processes logs in streaming
pm2 logs [--raw]
# Empty all log files pm2 reloadLogs # Reload all logs
pm2 flush - Actions
# Stop all processes pm2 restart all # Restart all processes
pm2 stop all
# Will 0s downtime reload (for NETWORKED apps)
pm2 reload all
# Stop specific process id pm2 restart 0 # Restart specific process id
pm2 stop 0
# Will remove process from pm2 list
pm2 delete 0
# Will remove all processes from pm2 list
pm2 delete all - Misc
# Reset meta data (restarted time...)
pm2 reset
# Update in memory pm2
pm2 updatePM2
# Ensure pm2 daemon has been launched
pm2 ping
# Send system signal to script
pm2 sendSignal SIGUSR2 my-app
pm2 start app.js --no-daemon
pm2 start app.js --no-vizion
pm2 start app.js --no-autorestart
pm2 start [echo.py](http://echo.py/)
pm2 start "pipenv run python -m scripts.script1"
pm2 start test.bash --interpreter bashtop
lsof -i:PORT
kill -9 PSID
nohup cmd &> output &Start
script ./output.txtStop
exitUFW
Enable
sudo ufw enableDefault port
sudo ufw allow 22Status
sudo ufw statusOpen port
sudo ufw allow 5500UFW guide
Run compose in bg
docker compose up -dfsck /dev/sda5