Caddy vs nginx: HTTPS, Config and Which to Pick
The headline difference is certificates. Caddy serves every site over HTTPS by default, fetching and renewing certificates from Let's Encrypt or ZeroSSL and redirecting HTTP for you. nginx needs certificate files you supply, from an ACME client or its separate acme module. Caddyfiles are shorter; nginx offers finer control and a much longer track record.
| Job | Caddy | nginx |
|---|---|---|
| HTTPS certificates | Automatic for any public domain in the config | You point ssl_certificate at files, or add the separate ngx_http_acme_module |
| HTTP to HTTPS redirect | Automatic | A port 80 server block that returns 301 |
| Compression | encode zstd gzip | gzip on |
| Reverse proxy | reverse_proxy localhost:3000 | proxy_pass in a location, plus headers |
| WebSockets through the proxy | Handled automatically | Forward Upgrade and Connection headers |
| Load balancing default | random | round robin |
| Active health checks | health_uri in reverse_proxy | health_check in the commercial edition only |
| Config check and reload | caddy validate, caddy reload | nginx -t, nginx -s reload |
Updated
Most comparisons stop at features. Here you can type a domain and an app port and get both configs, so you can see exactly how much each server asks you to write for the same result. Below the builder are side-by-side snippets for the jobs that come up most, then honest notes on where each one fits.
Caddyfile and nginx config builder
Type a domain, pick static files or a reverse proxy, and compare the two configs line for line.
The nginx version expects certificate files at the paths shown; get them from your ACME client first.
Load balancing three app servers
Caddyfile
Round robin across three backends, with background health checks against /healthz.
app.example.com {
reverse_proxy 10.0.0.11:8080 10.0.0.12:8080 10.0.0.13:8080 {
lb_policy round_robin
health_uri /healthz
}
}nginx
Round robin is the default. Open source nginx only checks health passively, through failed requests.
upstream app {
server 10.0.0.11:8080;
server 10.0.0.12:8080;
server 10.0.0.13:8080;
}
server {
listen 443 ssl;
server_name app.example.com;
ssl_certificate /etc/ssl/app.example.com/fullchain.pem;
ssl_certificate_key /etc/ssl/app.example.com/privkey.pem;
location / {
proxy_pass http://app;
}
}Proxying WebSockets
Caddyfile
reverse_proxy performs the upgrade and keeps a two-way tunnel open with no extra lines.
example.com {
reverse_proxy /ws/* localhost:8080
}nginx
The Upgrade and Connection headers must be passed on explicitly; proxy_http_version 1.1 is needed before nginx 1.29.7.
location /ws/ {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
What automatic HTTPS really covers
When a Caddyfile names a public domain, Caddy obtains a certificate through ACME, serves the site on 443, redirects port 80 to HTTPS and renews the certificate in the background. If one issuer fails it retries and can fall back to another. Nothing in the config mentions TLS unless you want to change the defaults.
nginx leaves this to you. The usual setup is an ACME client that writes certificate files and reloads nginx after renewing them, or the newer acme module that you install on purpose.
When nginx is the better fit
nginx is everywhere: in distributions, container images and hosting panels, with documentation and answers for nearly every situation. Teams that already run it, rely on particular modules, or need fine control over buffering and caching have little reason to move.
When Caddy is the better fit
Small teams, side projects and many domains benefit most from not managing certificates. Its native config format is JSON, which caddy adapt produces from a Caddyfile, and caddy reload pushes a new config to the running process through its admin API without downtime.
How it works
- Enter your domain and choose whether the server should hand out static files or forward requests to an app.
- Toggle compression and the www redirect to see which lines each server needs.
- Copy the Caddyfile next to the caddy binary and run caddy run, or copy the nginx block into a file under your sites folder.
- For nginx, get a certificate first with your ACME client and update the two certificate paths before reloading.
Tips
- Caddy can only obtain a public certificate if the domain's A or AAAA record points at the machine and ports 80 and 443 are reachable from outside.
- Give Caddy persistent, writable storage for its data directory. In containers, mount a volume, or it requests new certificates on every restart.
- Run caddy fmt on hand-edited Caddyfiles; it tidies indentation the same way every time.
- On nginx, test with nginx -t before every reload. It checks syntax and also tries to open files the config refers to, such as certificate paths.
- Since Caddy 2.8 the root directive no longer needs the * matcher, so root /srv works. Older guides that write root * /srv are still valid.
Frequently asked questions
Is Caddy a drop-in replacement for nginx?
For static sites, reverse proxies and simple load balancing, usually yes, and the config gets shorter. Large nginx setups using many third-party modules, complex map and rewrite logic, or tuned caching may not have a one-to-one Caddy equivalent, so translate and test one site at a time.
Does nginx do automatic HTTPS now?
nginx has an ngx_http_acme_module that implements ACME, but it is not built by default. You install it as a separate dynamic module (the nginx-module-acme package) and configure an issuer. Without it, certificates come from an external client.
Can Caddy give me HTTPS on localhost?
Yes. For localhost and internal names Caddy creates its own local certificate authority and issues certificates from it. Your system may ask once to trust its root certificate.
Which has better performance?
We do not publish speed numbers because they swing with hardware, TLS settings and workload. Both handle typical websites and APIs comfortably. If raw throughput matters for you, benchmark your own traffic pattern on your own servers.
Does Caddy support load balancing and health checks?
Yes. List several upstreams in reverse_proxy, choose an lb_policy such as round_robin or least_conn, and add health_uri for active checks or fail_duration for passive ones. Without a policy, Caddy picks upstreams at random.
Related: Apache vs nginx, nginx load balancing, SSL certificate types, DNS record types, Deploy a React app.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $19 a month.
More in Guides
- Call to Action Examples: 60 CTAs by Page Type | How-to Guide
- Cannot Read Properties of Undefined: Why and How to Fix
- Build a Car Dealership Website: Pages, Costs and a Working Example | How-to Guide
- Careers Page Examples
- What a CDN Does, Explained Plainly
- Contact Us Page Examples: 6 Small-Business Designs Annotated | How-to Guide
- Content Approval Workflow for Websites: Who Signs Off, When, and How to Stop It Becoming a Bottleneck | How-to Guide
- Cookie Consent Banner Examples You Can Copy
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App