Proxies·7 min read·

Reverse Proxy Fundamentals: Why Every Server Needs One

Learn what a reverse proxy does, when to put one in front of your apps, how it terminates TLS, and the security and performance wins it delivers for your VPS.

NB

Netbay Infrastructure Team

Netbay Engineering

On this page

What is a reverse proxy? Put simply, it is a server that sits in front of your application servers and forwards client requests to them on your behalf. Instead of a browser, a script, or a monitoring agent connecting directly to your Node.js or Python process, it connects to the reverse proxy, and the proxy is the only peer your app ever talks to. The name distinguishes it from a forward proxy, which sits in front of clients and relays their outbound traffic to the wider internet — we will cover those in a later post.

Most production sites on a single VPS can be drawn as a triangle: one public IP, one reverse proxy listening on ports 80 and 443, and one or more application servers bound to private addresses such as 127.0.0.1:3000 or 127.0.0.1:8080. Your app listens on localhost only. Nothing else on the internet can reach it except through the proxy, which is exactly the point.

Why every server wants one

  • **TLS in one place.** The proxy terminates HTTPS, so certificate and cipher configuration live in a single file instead of being duplicated across every app. Automatic certificate issuance makes this nearly free to set up.
  • **Port discipline.** Apps no longer need public ports. Run three services on the same box, all bound to localhost, and let the proxy decide which one handles each request.
  • **Cleaner failure handling.** If an upstream process dies, the proxy returns a configured error page or retries another backend instead of exposing a raw connection refusal to users.
  • **Single audit point.** One access log with client IPs, user agents, and status codes gives you one place to look when something goes wrong.

What the proxy does on each request

  1. It accepts the connection on port 443 and terminates TLS.
  2. It reads the Host header and the request path to select a route.
  3. It opens a connection to the chosen upstream and forwards the request, adding headers such as X-Forwarded-For and X-Real-IP.
  4. It streams the response back to the client and closes idle connections on both sides when done.

That is the whole contract. If you understand these four steps you can debug almost anything: TLS problems appear at step 1, routing problems at step 2, upstream health at step 3, and slow or partial responses at step 4.

The simplest possible Nginx setup

nginx
server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

This block sends every request for example.com to your app bound on port 3000. The Host header is preserved so the upstream can do host-based routing too, and the real client IP travels in X-Real-IP and X-Forwarded-For. Drop those headers and your app will log the proxy's address as the client, which quietly breaks rate limiting and audit trails.

Why a proxy changes your security posture

A reverse proxy is also a choke point. You can enforce rules in one place — block a list of IPs, rate-limit requests that hammer the login endpoint, reject suspicious user agents, or allow only a specific CIDR block to reach the admin panel. The app never has to implement any of this. A two-line allowlist in the proxy replaces what would otherwise mean custom middleware in every service you deploy. TLS, routing, logging, and access control all collapse into one process you can actually reason about.

Reverse proxy request flow Client public internet Reverse proxy TLS termination routing + rules access logging App server 127.0.0.1:3000 https:443 http:3000 Only the proxy listens on public ports. The app binds to localhost, so direct connections from the internet are impossible by default.

Takeaway

A reverse proxy is not an extra layer to avoid — it is the layer that makes TLS, routing, logging, and access control manageable on a single server. Start with one Nginx or Caddy instance in front of a single app and you are already on the proxy-first path. You can spin up an Ubuntu 24.04 instance on Netbay in under 60 seconds and follow along — netbayhosts.in.

Keep reading

Follow along on a real VPS

Deploy Linux in under 60 seconds

These guides are written against Ubuntu, Debian, and RHEL-family images — the same ones on NetBay.

Deploy an instance