On this pageWhat separates them
A server that runs several self-hosted apps needs one program on ports 80 and 443. It terminates TLS, picks the app by host name and hands the request to a container or a local port. Caddy and Nginx are the usual candidates, currently at Caddy 2.11 and Nginx 1.30 (stable) or 1.31 (mainline). Both proxy HTTP and WebSockets well, so the choice comes down to who manages certificates, how much configuration you want to maintain, and which features you need without custom builds. For PHP sites such as WordPress the questions differ; see Apache, Nginx or OpenLiteSpeed for WordPress.
What separates them
| Caddy | Nginx | |
|---|---|---|
| Certificates | Automatic, from Let's Encrypt with ZeroSSL as fallback | Certbot, or the separate ACME module |
| Wildcard certificates | DNS challenge through a provider module (custom build) | Certbot with a DNS plugin |
| WebSockets, forwarded headers | Handled by reverse_proxy |
Set by hand |
| HTTP/3 | On by default | quic listener; module still marked experimental |
| Rate limiting | Third-party module | Built in (limit_req) |
| Active health checks | Built in | Commercial NGINX Plus only |
| Configuration | Caddyfile, or JSON through an admin API | Directive files |
| License | Apache-2.0 | BSD-2-Clause |
Check where the package comes from before you compare anything. Ubuntu 24.04 and 26.04 both carry Caddy 2.6.2 in their archives, a release several years old, so install Caddy from its official apt repository. For Nginx, Ubuntu 24.04 has 1.24 and 26.04 has 1.28, while the nginx.org repository carries 1.30 and the newer modules described below.
One app behind each proxy
Take an app listening on 127.0.0.1:3000, published as app.example.com, that uses WebSockets for live updates.
Caddy
{
email admin@example.com
}
app.example.com {
encode zstd gzip
reverse_proxy 127.0.0.1:3000
log
}
That is the whole file. Caddy obtains the certificate on first start, redirects HTTP to HTTPS, renews before expiry and upgrades WebSocket connections without extra lines. It sets X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host for the app, and ignores those headers when clients send them unless you declare trusted ranges with the trusted_proxies server option, which you need behind a CDN. The log line enables access logs; without it Caddy writes none.
Nginx
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name app.example.com;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name app.example.com;
ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;
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;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 1h;
location / {
proxy_pass http://127.0.0.1:3000;
}
}
Enable the port 80 block first, then fetch the certificate and add the HTTPS block:
sudo certbot certonly --nginx -d app.example.com --deploy-hook 'systemctl reload nginx'
sudo nginx -t && sudo systemctl reload nginx
Nginx needs each piece spelled out. Upgrade and Connection are hop-by-hop headers, so WebSockets only work when you pass them on, and nginx closes a proxied connection that stays silent for 60 seconds unless you raise proxy_read_timeout. Since 1.29.7 nginx speaks HTTP/1.1 to upstreams by default; the proxy_http_version line is still required on older builds, including Ubuntu's, and harmless on newer ones. http2 on; needs 1.25.1 or later: on the 1.24 package of Ubuntu 24.04, write listen 443 ssl http2; instead. The proxy headers sit at server level so every location inherits them.
Certificates in Nginx without certbot
The nginx.org repositories now ship an official ACME module as a separate package, nginx-module-acme. It requests and renews certificates from inside nginx, with limits: it supports the HTTP-01 and TLS-ALPN-01 challenges only, cannot request wildcard names, and needs a resolver in the http block plus a port 80 listener for HTTP-01.
# nginx.conf, main context
load_module modules/ngx_http_acme_module.so;
# http context
resolver 127.0.0.53;
acme_issuer letsencrypt {
uri https://acme-v02.api.letsencrypt.org/directory;
contact admin@example.com;
state_path /var/cache/nginx/acme-letsencrypt;
accept_terms_of_service;
}
server {
listen 443 ssl;
server_name app.example.com;
acme_certificate letsencrypt;
ssl_certificate $acme_certificate;
ssl_certificate_key $acme_certificate_key;
ssl_certificate_cache max=2;
location / {
proxy_pass http://127.0.0.1:3000;
}
}
Point state_path at a persistent directory and never set it to off: it keeps the account key and certificates across restarts, so nginx does not go back to the CA at every start. It holds private keys, so restrict access to it.
Wildcard certificates need the DNS challenge
Let's Encrypt issues *.example.com only through DNS-01: the client proves control by creating a TXT record through your DNS provider's API. Stock Caddy and the nginx module cannot do that.
Caddy needs a build that includes your provider's module from the caddy-dns project. Build it with xcaddy, then divert the packaged binary so the apt package keeps its service file:
xcaddy build --with github.com/caddy-dns/cloudflare
sudo dpkg-divert --divert /usr/bin/caddy.default --rename /usr/bin/caddy
sudo mv ./caddy /usr/bin/caddy.custom
sudo update-alternatives --install /usr/bin/caddy caddy /usr/bin/caddy.default 10
sudo update-alternatives --install /usr/bin/caddy caddy /usr/bin/caddy.custom 50
sudo systemctl restart caddy
A custom binary no longer updates with apt, so rebuild it when a release ships. Pass the token through an EnvironmentFile readable by root only, then route every subdomain from one site block:
*.example.com {
tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}
@app host app.example.com
handle @app {
reverse_proxy 127.0.0.1:3000
}
@git host git.example.com
handle @git {
reverse_proxy 127.0.0.1:3001
}
handle {
abort
}
}
With Nginx, certbot does the DNS work and nginx only reads the files:
sudo apt install certbot python3-certbot-dns-cloudflare
sudo mkdir -p /etc/letsencrypt/secrets
sudo nano /etc/letsencrypt/secrets/cloudflare.ini # dns_cloudflare_api_token = ...
sudo chmod 600 /etc/letsencrypt/secrets/cloudflare.ini
sudo certbot certonly --dns-cloudflare \
--dns-cloudflare-credentials /etc/letsencrypt/secrets/cloudflare.ini \
-d example.com -d '*.example.com' \
--deploy-hook 'systemctl reload nginx'
Cloudflare is only the example; both projects have plugins for many providers. Limit the token to editing DNS in that one zone, because whoever holds it can change your records.
Customer domains: on-demand TLS
When customers point their own domains at your app, you cannot list those names in advance. Caddy's on-demand TLS obtains a certificate during the first handshake for a new name, and it has to be restricted: Caddy calls an endpoint of yours with ?domain= and the name, and proceeds only on a 2xx answer.
{
on_demand_tls {
ask http://127.0.0.1:9123/allowed
}
}
https:// {
tls {
on_demand
}
reverse_proxy 127.0.0.1:3000
}
Have the endpoint look the name up in your list of customer domains. Without that check, anyone could point domains at your server and make it request certificates until the CA rate-limits you. Nginx has no equivalent; you would run certbot per domain from your own code.
Limits, logs and protocols
Rate limiting
Nginx limits requests per client out of the box, which suits login and API paths:
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
server {
# listeners, certificates and proxy headers as above
location /login {
limit_req zone=login burst=10 nodelay;
limit_req_status 429;
proxy_pass http://127.0.0.1:3000;
}
}
Caddy's standard build has no rate limiter. The common choice, caddy-ratelimit, is a third-party module that needs a custom build, like the DNS module.
Logs
Nginx writes the combined format to /var/log/nginx/, which logrotate already handles on Ubuntu and almost every log tool parses. Caddy logs JSON to stderr, which systemd keeps in the journal; with output file it rolls the files itself. JSON suits log shippers and jq better than grep.
HTTP/3 and health checks
Caddy answers HTTP/3 by default, so open UDP 443 in your firewalls along with TCP 443. In nginx, HTTP/3 needs ngx_http_v3_module (look for --with-http_v3_module in nginx -V), a listen 443 quic reuseport; line beside the TLS listener (reuseport once per port) and an Alt-Svc header to advertise it. With several backends for one app, Caddy runs active health checks through health_uri; open source nginx only marks a backend down after failed requests (max_fails, fail_timeout).
Moving from Nginx to Caddy
- Translate site by site.
server_namebecomes the site address,locationblocks becomehandleorhandle_pathwith matchers,return 301becomesredirwithpermanent(Caddy's default is a temporary 302), and most proxy headers disappear. - Free the ports. Only one program can own 80 and 443, so stop and disable nginx before Caddy starts.
- Keep Caddy's data directory. The apt package stores certificates under
/var/lib/caddy. In Docker, mount a volume on/data, or every rebuilt container requests new certificates and runs into rate limits. - Switch with low TTLs. Lower DNS TTLs a day ahead, move the records, and watch
journalctl -u caddywhile the first certificates arrive.
If you would rather click than edit files, Nginx Proxy Manager puts a web interface on nginx, and Zoraxy is a reverse proxy managed from its own dashboard. Both trade flexibility for convenience.
Which one to install
- Caddy when one person runs a handful of apps and wants certificates to look after themselves, or when customers bring their own domains.
- Nginx when you need rate limits, caching or complex routing without custom builds, when the team already knows it, or when your apps ship nginx examples.
- Either for WebSockets, HTTP/2 and several sites on one server.
On CloudSat, Caddy and Nginx Proxy Manager are one-click apps, and Nginx installs on any Linux plan.
FAQ
Is Caddy fast enough to replace Nginx?
For a proxy in front of a few apps, the apps decide response times far more than the proxy. If you need numbers, load test your own configuration with the same TLS settings instead of relying on published benchmarks.
Can Caddy and Nginx run on the same server?
Yes, as long as only one of them listens on ports 80 and 443. A common pattern puts Caddy in front for certificates and keeps an existing nginx on a local port, serving PHP or static files behind it.
Do I need a reverse proxy for a single app?
Usually. It terminates TLS so the app never needs privileges for port 443, renews certificates, and makes a second app a matter of a few lines.
Where should the proxy run when apps are in Docker?
On the host, proxying to ports published on 127.0.0.1 only, or as a container on the same Docker network, reaching apps by service name. Publish app ports on 127.0.0.1 either way: Docker's published ports bypass UFW rules.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




