How to Set Up Nginx as a Reverse Proxy

An Nginx reverse proxy sits in front of your applications (n8n, Node.js, Flask, etc.) and handles incoming web traffic. It lets you run multiple apps on one server, add SSL, and serve apps on port 80/443 instead of obscure ports like 5678.

Step 1: Install Nginx

SSH into your server and run:

apt update && apt install nginx -y   (Ubuntu/Debian)

Verify Nginx is running: systemctl status nginx

Step 2: Create a Server Block for Your Domain

  1. Create a new config file:

nano /etc/nginx/sites-available/yourdomain.com

  1. Paste this configuration (replace yourdomain.com and the port number with your app's port):

server {

    listen 80;

    server_name yourdomain.com www.yourdomain.com;

 

    location / {

        proxy_pass http://127.0.0.1:5678;

        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;

    }

}

  1. Enable the site:

ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/

  1. Test the config and reload Nginx:

nginx -t && systemctl reload nginx

Step 3: Add SSL with Certbot (Free Let's Encrypt)

  1. Install Certbot:

apt install certbot python3-certbot-nginx -y

  1. Get and install a certificate:

certbot --nginx -d yourdomain.com -d www.yourdomain.com

  1. Follow the prompts. Certbot automatically updates your Nginx config to use HTTPS.
  2. Test auto-renewal:

certbot renew --dry-run

Common Use Cases for Nginx Reverse Proxy on Hordanso VPS

  • Serve n8n at https://n8n.yourdomain.com (proxy_pass to 127.0.0.1:5678)
  • Serve Grafana at https://grafana.yourdomain.com (proxy_pass to 127.0.0.1:3000)
  • Serve a Node.js/Express app at https://api.yourdomain.com (proxy_pass to 127.0.0.1:3000)

Note: Make sure your domain's DNS A record points to your VPS IP before running Certbot. Let's Encrypt verifies domain ownership via HTTP before issuing the certificate.

 

  • Nginx, server block, SSL Nginx, VPS, n8n Nginx, reverse proxy, proxy_pass
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Access Your VPS via SSH

SSH (Secure Shell) lets you connect to and manage your Hordanso VPS server from the command line....

How to Connect to VPS via PuTTY (Windows)

PuTTY is a free SSH client for Windows that lets you connect to and manage your Hordanso VPS...

How to Connect to Windows VPS via RDP

Remote Desktop Protocol (RDP) lets you connect to a Windows VPS with a full graphical desktop —...

How to Back Up Your VPS Data

Backing up your VPS is critical. Unlike shared hosting where Hordanso manages backups, VPS...

How to Install CyberPanel on Your VPS

CyberPanel is a free web hosting control panel built on OpenLiteSpeed — one of the fastest web...

Powered by WHMCompleteSolution