All Articles
Tech News9 min read

Nginx for Developers: Reverse Proxy and Load Balancing

How to serve your Node/Python apps properly. Static files, SSL termination, and basic routing.

T

TechGyanic

October 31, 2025

Nginx for Developers: Reverse Proxy and Load Balancing

You ran node server.js on port 3000. You are done, right? No. You need Nginx in front.

Why Nginx?

  1. Security: Hides your backend.
  2. Performance: Serves static files (images, css) much faster than Node.
  3. SSL: Handles HTTPS encryption.
  4. Load Balancing: Distributes traffic.

Basic Config (/etc/nginx/sites-available/default)

server {
    listen 80;
    server_name example.com;

    # Serve Static Files
    location /static/ {
        root /var/www/app;
        expires 30d;
    }

    # Reverse Proxy to Node.js
    location / {
        proxy_pass http://localhost:3000;
        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;
    }
}

Load Balancing

Run your app on ports 3000, 3001, 3002.

upstream myapp {
    server localhost:3000;
    server localhost:3001;
    server localhost:3002;
}

server {
    location / {
        proxy_pass http://myapp;
    }
}

Nginx will distribute requests round-robin style.

HTTPS with Certbot

Don't buy certs. Use Let's Encrypt.

sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com

It auto-configures SSL in your Nginx file.

Nginx is the "glue" of the internet. Even basic knowledge separates you from the average dev.

nginxdevopsbackendserverdeployment
Share this article
T

Written by

TechGyanic

Sharing insights on technology, software architecture, and development best practices.