Installation

sudo apt install nginx -y

Basic configuration for upstream

upstream app {
    server                <IP/localhost>:<port>;
}

server {
    server_name           sub.domain.ru;

    location / {
        proxy_pass        <http://app>;
        proxy_set_header  Host $host;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
  1. Place test.conf in /etc/nginx/sites-available
  2. Make symbolic link to file in sites-enabled to turn on configuration
ln -s /etc/nginx/sites-available/test.conf /etc/nginx/sites-enabled/
  1. Test configuration
nginx -t
  1. Reload nginx configs without downtime
nginx -s reload

Cert

sudo apt install python3 python3-venv libaugeas0 -y

Install Let's Encrypt SSL on Ubuntu with Certbot | InMotion Hosting