How to set up Nginx as a reverse proxy
Updated 7/20/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 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 7/20/2026Web serversHow to install phpMyAdmin to manage MySQL from the browser
Manage your MySQL databases from a web interface with phpMyAdmin, installed and secured correctly.
Updated 7/20/2026Web serversHow to host a static site or a React/Vue app
Publish a static site or a React/Vue build on Nginx, with correct routing for single-page apps.
Updated 7/20/2026