nginx to Caddyfile Converter
Converts nginx server blocks to a Caddyfile, mapping server_name, root, location blocks, proxy_pass and upstream groups, return, add_header, gzip, try_files, fastcgi_pass and ssl_certificate.
Use the tool
Why this tool exists
Caddy appeals because a few lines replace a long nginx configuration, and it manages HTTPS for you. The hard part is translating an existing nginx setup: location blocks with prefixes, exact matches and regular expressions, proxy_pass with upstream groups, redirects, headers and PHP. This tool maps these to handle, handle_path, reverse_proxy, redir, respond, header, encode, try_files and php_fastcgi. Servers that only redirect HTTP to HTTPS are dropped, since Caddy does that automatically. Directives with no known equivalent are left as comments. Check the result with caddy validate before use. The conversion runs in your browser, so your server configuration is not uploaded.
How to use it
- Paste your nginx configuration, including any upstream blocks, into the input box.
- Run the conversion to get the Caddyfile.
- Review the comments for unsupported directives and check the result with caddy validate.
Frequently asked questions
Why are some servers missing from the output?
A server block that only redirects HTTP to HTTPS is dropped, because Caddy enables HTTPS and the redirect automatically for sites with a domain name.
How are location blocks converted?
Prefix, exact and regex locations become handle or handle_path blocks with matchers. Pay attention to path stripping, which differs between nginx proxy_pass and Caddy handle_path.
What happens to certificates?
ssl_certificate and ssl_certificate_key become a tls directive with the same files. Remove it if you want Caddy to obtain certificates itself.
Does the output need checking?
Yes. Unsupported directives stay as comments, and subtle behaviour such as rewrites and proxy headers can differ. Run caddy validate and test the site.