A reverse proxy acts as a middleman between clients and your backend servers. It improves security, handles HTTPS, load balancing, and allows multiple apps to share the same VPS IP.
Step 1: Install Nginx
Make sure your VPS is updated and install Nginx:
Start and enable Nginx:
Verify installation:
Step 2: Configure a Basic Reverse Proxy
Suppose you have a web app running on port 3000. You can proxy requests from port 80 (HTTP) through Nginx:
-
Edit a new Nginx site configuration:
Add:
-
Enable the site:
Now, visiting http://yourdomain.com will serve your app on port 3000 through Nginx.
Step 3: Enable HTTPS with Let’s Encrypt
Secure your reverse proxy traffic:
-
Install Certbot:
-
Obtain and install SSL certificate:
Certbot will automatically modify your Nginx config to redirect HTTP → HTTPS.
-
Test auto-renewal:
Step 4: Advanced Reverse Proxy Features
-
Load balancing: If you have multiple backend servers:
-
Caching static content: Improves performance for static files.
-
WebSocket support: Add headers if your app uses WebSockets:
✅ Tips & Best Practices
-
Keep your Nginx configuration organized by creating separate files for each app.
-
Always test Nginx after changes:
nginx -t. -
Use fail2ban to protect your server from brute-force attacks.
-
Reverse proxies are ideal for hosting multiple apps on the same VPS with a single IP.
With a reverse proxy setup, your VPS can securely host multiple apps, handle HTTPS traffic, and efficiently route requests — all while keeping your backend servers isolated.