This describes how to set up and use nginx on Debian 10 Buster


Installation

Ensure your server is up to date with apt-get update & apt-get upgrade.
Install nginx with "apt-get install nginx".

Recommended: instal ufw and allow ports 80 and 443 with ufw allow 80,443/tcp.
Ensure nginx is running with systemctl status nginx, there should be a green text reading Active: active (running)

Your nginx server should now be set up.

Configuration

Creating new site configurations (the default configuration will serve from /var/www/html on any requests not matching other sites).

Step 1 Create new site file with nano /etc/nginx/sites-available/site-name
Step 2 Create a directory for the site for example mkdir /var/www/homepage
Step 3 Set up site for HTTP, paste in the following;

Global nginx configuration

Step 1 Open the configuration file with nano /etc/nginx/nginx.conf
Step 2 Change any settings you may want to in this file, most commonly you may want to change loggin locations access_log and error_log

Proxying

A proxy can be used to redirect a subdomain to another location without adding a new A record to your DNS

Step 1 Create a file to store proxy configs in (this can be either one file or multiple) using nano /etc/nginx/conf.d/proxy.conf
Step 2 Paste in a new server configuration (this example proxies requests to http://mail.domain.com to http://www.gmail.com)

Don't forget to restart nginx with systemctl, restart nginx after any changes to the config