← Back to VPS & Dedicated

How to Set Up a Reverse Proxy

A reverse proxy sits in front of your application server, handling SSL termination, load balancing, and caching. Nginx is commonly used as a reverse proxy in front of Node.js, Python, or other app servers.

What a Reverse Proxy Does

  • Accepts HTTPS connections and forwards plain HTTP to the backend
  • Distributes load across multiple backend servers
  • Serves static files directly without hitting the app
  • Hides the backend server and port from the public

Nginx as a Reverse Proxy

Example: proxy requests to a Node.js app running on port 3000:

server {\n  listen 80;\n  server_name yourdomain.com;\n\n  location / {\n    proxy_pass http://127.0.0.1:3000;\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade $http_upgrade;\n    proxy_set_header Connection 'upgrade';\n    proxy_set_header Host $host;\n    proxy_cache_bypass $http_upgrade;\n  }\n}

Adding SSL with Certbot

Install Certbot and get a free SSL certificate for your Nginx reverse proxy:

apt install certbot python3-certbot-nginx -y\ncertbot --nginx -d yourdomain.com

Certbot automatically modifies your Nginx config to handle HTTPS and sets up auto-renewal.

Was this article helpful?

On This Page