A reverse proxy on a VPS is a small piece of software that sits between the internet and the apps running on your server. Visitors connect to the proxy, and the proxy passes each request on to the right app, then returns the answer. Your apps never face the internet directly. One $5 VPS can host a WordPress site, a Node app, and a self-hosted dashboard this way, each on its own domain, all sharing ports 80 and 443.
If you have ever run two web apps on one server and wondered how both can answer on port 443, this is the answer. This guide explains what a reverse proxy does, when it is worth adding, and how to set one up with Nginx, including free HTTPS.
What a Reverse Proxy Actually Does
Picture a reception desk in an office building. Visitors arrive at one front door, state who they came to see, and the receptionist sends them to the right floor. A reverse proxy plays the same role for your server. It listens on ports 80 and 443, reads the domain name in each request, and forwards it to the app that owns that domain. Your WordPress site might run on PHP-FPM, your Node app on port 3000, and a dashboard on port 8080. None of those ports need to be open to the world, because the proxy is the only public-facing process, and it also gives you one place to add HTTPS, rate limiting, and access logs.
Reverse Proxy vs Forward Proxy: What Is the Difference?
The names sound alike, but the two proxies sit on opposite sides of the connection. A reverse proxy vs forward proxy comparison comes down to who it protects. A forward proxy sits next to the client: your browser sends its requests through it, and the website sees the proxy, not you.
A reverse proxy sits next to the server. Visitors see the proxy, not your apps. It hides your app servers, balances load between them, and terminates TLS so the apps behind it can stay simple. If you run a VPS and want several apps behind one domain setup, you want a reverse proxy.
When a Reverse Proxy Earns Its Place on Your VPS
A reverse proxy is worth the extra moving part when you run more than one web app on one server. Without a proxy, only one app can own port 443, and the rest end up on odd ports visitors have to type by hand. With a proxy, each app gets its own subdomain and the port numbers stay hidden.
The second is HTTPS. A proxy terminates TLS once, at the edge, so each app behind it can speak plain HTTP on localhost. You manage one certificate per domain in one place instead of wiring TLS into every app, and Certbot handles renewal for you. The third is protection: rate limits, bot blocking, and security headers set once in the proxy config cover every app behind it. If one app later grows enough to need load balancing across several instances, the proxy is already the place to do it.
Nginx, Caddy, or Nginx Proxy Manager?
Nginx is the default choice: fast, stable, and already installed on most LEMP stacks. You write server blocks by hand, which gives you full control over headers, caching, and rate limits. If you already run Nginx for WordPress, adding proxy blocks costs nothing extra.
Caddy trades control for convenience. Its config is a few lines per site, and it fetches and renews TLS certificates on its own, with no Certbot step. The trade-off is less fine-grained control over caching than Nginx. It suits a small stack where you want HTTPS with almost no config.
Nginx Proxy Manager puts a web dashboard in front of Nginx. You add proxy hosts by filling in a form, and it handles certificates for you. It is the friendliest option if you dislike editing config files, but it runs in Docker and hides the generated config, which makes debugging harder when something breaks. Our guide to setting up Nginx Proxy Manager with Docker walks through the install if you prefer the dashboard route. For the rest of this guide, we use plain Nginx, because the config you write is the config you can read back later.
How to Set Up a Reverse Proxy on a VPS with Nginx
This nginx reverse proxy setup assumes Ubuntu 24.04, Nginx already installed, and a Node app listening on port 3000 at 127.0.0.1. The same steps work for any app on localhost, whether it is Node, Python, Go, or a Docker container.
Step 1: Create a server block for the app
Open a new file at /etc/nginx/sites-available/app.example.com and add a server block. The proxy_pass line is the heart of the setup: it tells Nginx where to send requests for this domain. The nginx proxy_pass configuration below also forwards the real visitor IP and protocol, so your app logs see the truth instead of 127.0.0.1.
server {
listen 80;
server_name app.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
proxy_cache_bypass $http_upgrade;
}
}
The Upgrade and Connection headers matter if your app uses WebSockets. Without them, live features like chat drop the connection right after loading. The X-Forwarded-Proto header matters too: it tells the app the visitor arrived over HTTP or HTTPS, so it builds correct redirect URLs instead of looping.
Step 2: Enable the site and test the config
Link the file into sites-enabled and test before reloading, so a typo never takes Nginx down:
sudo ln -s /etc/nginx/sites-available/app.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
If nginx -t reports a syntax error, fix it first. A reload with a broken config keeps the old one running, but a restart would not, so test-then-reload is the habit that keeps your sites up.
Step 3: Point the domain at your VPS
In your DNS provider, add an A record for app.example.com pointing at your VPS IP address. DNS changes can take a few minutes to a few hours to spread, so check with dig app.example.com before assuming the config is wrong.
Step 4: Repeat the block for each app
Each app gets its own server block with its own domain and port. Keep one file per domain; a single giant config file turns into a mess the first time you need to remove one site. If the app runs in Docker, the only change is the target address. See our guide to configuring Nginx as a reverse proxy for Docker containers for the container-specific details.
Add Free HTTPS with Certbot
With the HTTP proxy working, add TLS. Install Certbot and the Nginx plugin, then ask it to fetch a certificate for the domain. It edits your server block, adds the redirect from HTTP to HTTPS, and sets up renewal:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d app.example.com
Test renewal with sudo certbot renew --dry-run. If the dry run passes, certificates renew on their own. If you have not pointed a domain at the server yet, start with our guide on how to point a new domain to your VPS and set up free HTTPS.
Four Mistakes That Break a New Reverse Proxy
Forgetting the Host header. If proxy_set_header Host $host; is missing, the app behind the proxy sees “127.0.0.1” as the host and may serve the wrong site or reject the request. Always pass the real host through.
Redirect loops. Your app redirects HTTP to HTTPS, the proxy passes the request as HTTP on localhost, and the app redirects again. The fix is the X-Forwarded-Proto header plus telling the app to trust it, or letting the proxy handle the HTTP-to-HTTPS redirect.
Uploads that fail at a small size. Nginx caps request bodies at 1 MB by default. File uploads larger than that die with a 413 error. Add client_max_body_size 50m; inside the server block, sized to what your app actually accepts.
Frequently Asked Questions
Does a reverse proxy slow down my site? The overhead is small, usually a millisecond or two on localhost, and caching at the proxy can make the site faster overall. A proxy only becomes a bottleneck on a VPS that is already short on CPU or RAM.
A reverse proxy is a small amount of config that pays off the moment your VPS hosts more than one thing. Start with one server block, test it, add HTTPS, and repeat the pattern per app. Keep one file per domain and keep the headers consistent, and the proxy stays boring in the best sense: invisible, until the day you need to change where an app lives, and then it is a one-line edit.