week 11.3 aws, certificate, pm2
//sudo apt update
//sudo apt install nginx
this should start a nginx start on port 80
create reverse proxy
//sudo rm /etc/nginx/nginx.conf
//sudo vi /etc/nginx/nginx.conf
events {
# Event directives...
}
http {
server {
listen 80;
server_name be1.100xdevs.com;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
//sudo nginx -s reload
use this when you have internet issue
//sudo vi /etc/resolve.conf //and set server 8.8.8.8
//npm i -g pm2 // this will use to run code foreever
always present in the folder where your server file
//pm2 start index.js
=============================================
user lets certbot site
install cerbot to get secure connection on user and server
// sudo snap install --classic certbot
prepare the certbot command
// sudo in -s /snap/bin/certbot /usr/bin/certbot
choose how you'd like to run certbot or generate certificate
//sudo certbot --nginx
then it will ask you which server will you certified
1. To run the application using pm2, navigate to your application directory and run the following command:
// pm2 start app.js2. This will configure pm2 to start your application automatically whenever the server restarts.
// pm2 start app.js --startup3. To stop or restart your application, you can use the following commands:
// pm2 stop app.js
// pm2 restart app.js
Comments