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

Ensure your server is up to date with apt-get update && apt-get upgrade.
Install nginx with apt-get install nginx.
Recommended: Install ufw and allow ports 80 and 443 with ufw allow 80,443/tcp.
Ensure nginx is running with systemctl status nginx, there should be green text reading Active: active (running).
Your nginx server should now be set up.

Creating new site configurations (The default configuration will serve from /var/www/html on any requests not matching other sites)
Create new site file with nano /etc/nginx/sites-available/site-name
Create directory for the site for example mkdir /var/www/homepage
Set up site for HTTP, paste in the following
server {
listen 80;
listen [::]:80;
root /path/to/root/directory;
index index.html index.htm index.php index.asp index.aspx;
location / {
try_files $uri $uri/ = 404

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

A proxy can be used to redirect a subdomain to another location without adding a new A record to your DNS
Create a file to store proxy configs in (this can be either one file or multiple) using nano /etc/nginx/conf.d/proxy.conf
Paste in a new server configuration (this example proxies requests to to
server {
listen 80;
location / {

Don't forget to restart nginx with systemctl restart nginx after any changes to the config
Was this article helpful?
Thank you!