- Running server
- Ability to SSH into your server
- Exposed public ports 80 and 443
- DNS records set to point to your server's IP address
- NodeJS and Git installed on the server
Follow these Steps: NGINX Installation Guide
- Install NGINX
- Start NGINX via
sudo systemctl start nginx - Open your host URL in the browser (Important: Use http, not https)
- Add your host URL to the
server_nameviasudo nano /etc/nginx/conf.d/default.conf(check the template default.confd for reference) - Validate your NGINX config via
sudo nginx -t - Restart NGINX via
sudo systemctl restart nginx
- Install Certbot via
sudo apt-get install certbot python3-certbot-nginx - Start the certification process:
sudo certbot --nginx -d [YOUR_HOST_URL](append as many-d [HOST_URL]as are pointing to your server) - If the certificate was generated, but could not be installed, manually update your
/etc/nginx/conf.d/default.confto match default.ssl.conf up to line 34 (Don't forget to update the placeholders!) - Validate your NGINX config via
sudo nginx -t - Restart NGINX via
sudo systemctl restart nginx
- Install the dependencies in
nginx-tutorial/basic-api - Start a tmux session
tmux new -s apisession - Run
npm run prod - Detach you tmux session
[CTRL + B] >> D - Open your
/etc/nginx/conf.d/default.conf - Add the following to your existing https server block:
location /api {
proxy_pass http://127.0.0.1:3000;
}
- Validate your NGINX config via
sudo nginx -t - Restart NGINX via
sudo systemctl restart nginx
- Install the dependencies in
nginx-tutorial/basic-service - Start a tmux session
tmux new -s servicesession - Run
npm run prod - Detach you tmux session
[CTRL + B] >> D - Open your
/etc/nginx/conf.d/default.conf - Add the following at the very bottom of the file:
upstream basicService {
server 127.0.0.1:4000;
server 127.0.0.1:4001;
}
server {
listen 3333;
location / {
proxy_pass http://basicService;
}
}
- Validate your NGINX config via
sudo nginx -t - Restart NGINX via
sudo systemctl restart nginx