Nginx to Caddy Converter
Paste an nginx server block and convert it to a clean Caddyfile.
Client-side only — nothing leaves your browser
example.com, www.example.com {
root * /var/www/example
encode gzip
header X-Frame-Options SAMEORIGIN
header Strict-Transport-Security max-age=31536000
tls /etc/ssl/example.com.crt /etc/ssl/example.com.key
handle /* {
try_files {path} {path}/ =404
file_server
}
handle /api/ {
reverse_proxy 127.0.0.1:3000
}
handle /old {
redir https://example.com/new
}
handle /admin {
# basicauth requires hashed credentials — generate with: caddy hash-password
basicauth {
# Convert /etc/nginx/.htpasswd entries to: <user> <bcrypt-hash>
# user JDJhJDE0...
}
}
}Manual review needed
- auth_basic for "/admin" was scaffolded — generate hashes with "caddy hash-password".
What this converter does
This tool parses a single nginx server block and rewrites it as the equivalent Caddyfile. It maps the most common directives — server_name, listen, root, location, proxy_pass, try_files, return 301, TLS certificates, gzip, headers, and basic auth. Anything it cannot translate is flagged in a notes panel so you can fix it by hand. Conversion happens entirely in your browser — your config never leaves the page.
Nginx to Caddyfile directive mapping
| Nginx | Caddyfile | Notes |
|---|---|---|
| server_name example.com | example.com (site address) | Multiple names → comma-separated |
| listen 80; listen 443 ssl | (no directive) | Caddy auto-enables HTTPS for domains |
| root /var/www/site | root * /var/www/site | Caddy needs a matcher (use *) |
| index index.html | file_server | file_server serves index files automatically |
| location / { try_files $uri =404 } | handle /* { try_files {path} =404; file_server } | {path} replaces $uri |
| proxy_pass http://127.0.0.1:3000 | reverse_proxy 127.0.0.1:3000 | Strip http:// — Caddy infers it |
| proxy_set_header X-Real-IP $remote_addr | (omitted) | reverse_proxy sets X-Forwarded-* automatically |
| return 301 https://example.com$request_uri | redir https://example.com{uri} | Use redir for permanent redirects |
| ssl_certificate /path/cert.crt | tls /path/cert.crt /path/key.key | Combine cert + key on one line |
| add_header X-Frame-Options SAMEORIGIN | header X-Frame-Options SAMEORIGIN | Caddy header replaces by default |
| gzip on | encode gzip | Use 'encode gzip zstd' for both |
| auth_basic / auth_basic_user_file | basicauth { user <bcrypt-hash> } | Generate hash with caddy hash-password |
| client_max_body_size 50M | request_body { max_size 50MB } | Caddy uses MB/GB suffixes |
Nginx variables → Caddy placeholders
Caddy uses {placeholder} braces instead of nginx $variable syntax. This converter rewrites the most common ones inside proxy_set_header values automatically:
| Nginx | Caddy |
|---|---|
| $host | {host} |
| $http_host | {host} |
| $remote_addr | {remote_host} |
| $proxy_add_x_forwarded_for | {remote_host} |
| $scheme | {scheme} |
| $request_uri | {uri} |
| $uri | {path} |
| $args / $query_string | {query} |
Why migrate from Nginx to Caddy?
- Automatic HTTPS. Caddy provisions and renews Let's Encrypt or ZeroSSL certificates with zero configuration. No certbot, no cron jobs, no renewal scripts.
- Simpler config. A typical Caddyfile is roughly 40-60% shorter than the equivalent nginx config because sensible defaults (HTTPS redirect, security headers, HTTP/2, HTTP/3 via QUIC) are on by default.
- First-class HTTP/3. Caddy enables HTTP/3 (QUIC) by default; nginx requires a build flag and manual tuning.
- Live config reload. Caddy can reload via API without dropping connections — handy for dynamic environments.
- Single static binary. Caddy ships as one Go binary with no runtime dependencies, which simplifies containers and edge deployments.
What this tool can't convert
Some nginx features have no direct Caddyfile equivalent or require a custom Caddy module. The converter will flag these in the notes panel:
- Complex regex locations (
~/~*) — Caddy uses named matchers ifblocks (nginx's if is evil) — refactor with@matcherblocksmapdirectives — use Caddymaphandler- FastCGI / PHP-FPM (
fastcgi_pass) — usephp_fastcgi - Stream (TCP/UDP) blocks — Caddy needs the
layer4module - Rate limiting and WAF rules — require third-party Caddy modules
- Upstream load-balancing pools — express as space-separated upstreams in
reverse_proxy
Frequently Asked Questions
Is Caddy similar to Nginx?
What is the difference between Nginx and Caddy?
Is Caddy faster than Nginx?
Where should I put my Caddyfile?
How do I reload Caddy after editing the Caddyfile?
Related Tools
Need to manage SSH connections?
SSH Workbench lets you connect, browse files, and manage servers visually.
Try SSH Workbench Free