How to set up Nginx as a reverse proxy
Updated 10/16/2026
Modern apps (Node, Python, Java) run on an internal port, for example 3000. An Nginx reverse proxy receives traffic on port 80/443 and forwards it to the app, handling the domain and HTTPS.
Why you need a reverse proxy
- Serve on the standard 443 port with HTTPS, not on an odd port.
- Run multiple apps on one server, each with its own domain.
- Add caching, compression and rate limiting in one place.
Configuration
Assume the app runs on 127.0.0.1:3000. Create the server block:
server {
listen 80;
server_name app.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
nginx -t && systemctl reload nginx
Add HTTPS
Run Certbot for a free certificate; see Free SSL certificate with Let's Encrypt. To run the Node app as a service, see How to deploy a Node.js app.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How to deploy a Laravel app to production
Deploy Laravel properly on a VPS: Nginx, PHP-FPM, permissions, optimizations and the queue worker.
Updated 10/16/2026Web serversHow to optimize Nginx performance: gzip, cache and HTTP/2
Make your site faster with gzip compression, static file caching and HTTP/2, a few lines of config.
Updated 10/16/2026Web serversHow to force HTTPS and redirect HTTP
After installing SSL, make sure every visitor uses HTTPS, with a permanent 301 redirect from HTTP.
Updated 10/16/2026