← Blog
A lavender selector-switch box with an ivory faceplate and an orange lever on a pale lavender background.
Published on
2026-11-17

Caddy vs Nginx: choose a reverse proxy

Caddy and Nginx can sit between a client and an application, receive HTTP requests, and forward them to a backend. Caddy is a strong starting point for a small new setup when concise configuration and integrated HTTPS automation fit the job. Nginx is a sensible choice when your team already operates it or depends on its configuration and modules.

The useful comparison is the work around the proxy: certificates, request handling, trusted headers, updates, reloads, and failure diagnosis. If you are still deciding who should operate that infrastructure, start with the API hosting guide.

Compare the operating requirements

DecisionCaddyNginx
A small HTTP reverse proxyA Caddyfile can express the basic route with little configuration.A server and location block make the route and forwarding settings explicit.
Certificate automationAutomatic HTTPS is integrated, subject to hostname and challenge requirements.Automation can use the official ACME module or another certificate-management tool. Check the installed package and modules.
Existing configurationEvaluate migration effort and the modules your application needs.Keeping a working, maintained configuration can be cheaper than replacing it.
Configuration changesThe CLI can validate and reload configuration through the admin API.Configuration testing and reload commands support a controlled update process.
Production performanceMeasure the actual workload and deployment.Measure the actual workload and deployment. Windows results do not represent Linux capacity.

This comparison concerns Caddy and Nginx themselves. Nginx Proxy Manager is a separate management application, and a feature in Nginx Plus should not be assumed to exist in every open-source Nginx installation.

Check how HTTPS will work

Caddy automatic HTTPS handles certificate management and HTTP-to-HTTPS redirects when the configuration qualifies. Public certificate issuance still depends on a valid domain and a working verification path. Local certificates have a different trust model.

Nginx also has an official ACME module. Its availability and configuration depend on the build or package you install. Claims that Nginx always requires manual certificate renewal are outdated. Compare the actual components you would operate, including certificate storage and renewal monitoring.

If a hosting gateway terminates HTTPS before forwarding traffic to your application, map that connection separately. A public HTTPS URL does not prove that the connection from the gateway to the backend is encrypted, or that you can issue certificates for an arbitrary custom domain. Neither proxy configuration below adds application authentication.

Use the same backend for a functional comparison

The following local exercise uses Python 3.12.14, Caddy 2.11.9, and Nginx 1.31.8 on Windows. It checks HTTP behavior without requesting certificates or exposing a public listener. Use a new working directory and unused ports. Obtain the binaries from the official Caddy installation sources and the Nginx download page.

A small echo application

Save this as backend.py. It reports the request received by the application and supplies two deliberate error paths. It is a local diagnostic server, not a production application server.

"""Local echo backend for the reverse-proxy comparison."""
import argparse
import json
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

class Handler(BaseHTTPRequestHandler):
    def respond(self):
        length = int(self.headers.get("Content-Length", "0"))
        body = self.rfile.read(length).decode("utf-8")
        status = 503 if self.path == "/upstream-error" else 404 if self.path == "/missing" else 200
        payload = json.dumps({
            "method": self.command,
            "target": self.path,
            "body": body,
            "host": self.headers.get("Host"),
            "forwarded_for": self.headers.get("X-Forwarded-For"),
            "forwarded_proto": self.headers.get("X-Forwarded-Proto"),
        }).encode("utf-8")
        self.send_response(status)
        self.send_header("Content-Type", "application/json")
        self.send_header("Content-Length", str(len(payload)))
        self.end_headers()
        self.wfile.write(payload)

    do_GET = respond
    do_POST = respond

    def log_message(self, *args):
        pass

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--port", type=int, default=19000)
    args = parser.parse_args()
    ThreadingHTTPServer(("127.0.0.1", args.port), Handler).serve_forever()

Run python backend.py --port 19000 in one terminal. The backend listens only on 127.0.0.1.

Caddy configuration

Save this as Caddyfile. The HTTP listener accepts any Host value but binds only to loopback; that lets the exercise inspect a supplied Host header. Automatic HTTPS is disabled. The admin endpoint is also local.

{
    admin 127.0.0.1:12019
    auto_https off
}
http://:18080 {
    bind 127.0.0.1
    header X-Proxy-Revision one
    reverse_proxy 127.0.0.1:19000 {
        transport http {
            dial_timeout 2s
            response_header_timeout 2s
        }
    }
}

From another terminal in that directory, use caddy validate --config Caddyfile --adapter caddyfile, then caddy run --config Caddyfile --adapter caddyfile. Use the executable's full path if it is not on your PATH. The reverse_proxy reference explains forwarding defaults and options.

Nginx configuration

Save this as nginx.conf in the same working directory and create logs and temp subdirectories. Nginx's Windows build needs the temporary-directory parent to exist. The proxy listens on a different local port, so both can run beside the same backend.

worker_processes 1;
error_log logs/error.log notice;
pid logs/nginx.pid;

events {
    worker_connections 128;
}

http {
    access_log off;
    server {
        listen 127.0.0.1:18081;
        server_name _;
        add_header X-Proxy-Revision one always;
        location / {
            proxy_pass http://127.0.0.1:19000;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_connect_timeout 2s;
            proxy_read_timeout 2s;
        }
    }
}

Use that directory as Nginx's prefix: nginx -p /absolute/path/to/working-directory/ -c nginx.conf -t checks the configuration; the same command without -t starts it. On Windows, use an absolute path with forward slashes, such as C:/proxy-demo/. Quote a path containing spaces.

Both examples preserve the request path. Nginx's proxy_pass here has no URI after the upstream address. Adding a URI changes its replacement behavior; the Nginx proxy-module reference explains that distinction.

Inspect the responses and failure modes

Send the same requests to ports 18080 and 18081, with Host: example.test. For example, request /api/items?q=a%20b&n=2, then send a JSON POST to /api/items. Inspect what the backend received rather than checking only for HTTP 200.

CheckObserved locally
Path and encoded queryBoth preserved /api/items?q=a%20b&n=2.
POST and UTF-8 bodyBoth preserved the method and the JSON body containing café.
Host headerBoth passed example.test to the backend.
Supplied forwarding headersBoth configurations replaced the forged client address and scheme with 127.0.0.1 and http.
Backend returns an errorBoth preserved the deliberate 404 and 503 responses.
Configuration reloadChanging X-Proxy-Revision from one to two appeared in subsequent responses.
Backend stoppedCaddy returned 502. Nginx returned 504; its log recorded a connection timeout.

All 24 checks passed, including configuration acceptance and stopping the test listeners. These are local functional observations. They do not measure throughput, concurrent traffic, certificate renewal, a Linux service, or a deployment on Hivenet. Nginx documents its Windows build's limitations, so this exercise cannot identify a production performance winner.

The forwarding-header test assumes the immediate caller is the client. Behind a trusted gateway, overwriting those fields with the gateway's address and internal HTTP scheme may lose information you need. Define which upstream proxies are trusted and configure both the proxy and application accordingly. Do not accept arbitrary client-supplied forwarding headers as authoritative.

A backend-generated 503 and an unreachable backend are different failures. The latter can appear as a gateway error or timeout, depending on the connection and settings. Record status, logs, and timing together before changing retry behavior, especially for requests that modify data.

Plan reloads, limits, and production checks

For Caddy, change the configuration and run caddy reload --config Caddyfile --adapter caddyfile --address 127.0.0.1:12019. The Caddy CLI reference also documents validation and shutdown. For Nginx, repeat the prefix and configuration arguments, test with -t, then use -s reload. See the Nginx configuration-control documentation.

The reload check above observed a changed response header. It did not test uninterrupted long-running requests. Streaming, WebSockets, uploads, buffering, request-size limits, and timeouts deserve separate tests with the behavior your application actually uses. The two-second limits in these examples are deliberate test settings, not recommended production values.

After the exercise, stop Caddy with caddy stop --address 127.0.0.1:12019. Stop this Nginx instance with the same prefix and configuration arguments plus -s quit, and stop the Python terminal with Ctrl+C. Do not apply a global process-kill command to a machine that runs other proxies.

Before deployment, set intended hostnames, access controls, log retention, health checks, update procedures, and recovery behavior. If the backend moves into a separate container, its loopback address changes meaning. The Docker Compose networking guide explains when to use service names and container ports.

Choose the proxy and the hosting model together

Choose Caddy when its configuration and integrated certificate workflow reduce the work for your specific service. Keep or choose Nginx when your existing configuration, required modules, and team experience support it. Test a migration against real routes and clients before removing the old setup.

A reverse proxy and a typical web API can run on CPU infrastructure. Compute with Hivenet is one option for workloads you operate yourself. Review the vCPU documentation, required instance access, and current connectivity options before choosing a configuration.

Use SSH port forwarding for private access when it fits the task. Confirm the public endpoint and TLS path separately. The proxy choice does not establish VM capacity or turn infrastructure into a managed application service. Once the application works, measure it on the intended instance and budget for the work of operating it.

Your next workload belongs on Hivenet.

Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.