All Tools View Categories About Contact Privacy

Caddyfile to Nginx Converter

Translate a Caddyfile into an nginx server block preserving reverse proxy, static and TLS directives.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
Your converted nginx config will appear here.
-
servers
-
upstreams

About Caddyfile to Nginx Converter

Caddy made writing web server config pleasant: a clean, indentation-light Caddyfile with reverse_proxy, file_server and automatic TLS. But many teams still need or prefer nginx for its ubiquity, module ecosystem and existing tooling. Hand-converting a Caddyfile is error-prone - Caddy matchers, global options and automatic HTTPS do not map one-to-one onto nginx directives, and a missing proxy header or a forgotten listen directive can quietly break a site. The Caddyfile to Nginx Converter reads a pasted Caddyfile and emits a correct, self-contained nginx server block, then validates the result before you copy it.

At the heart of the configuration are a handful of directives. listen opens the port nginx serves on; the converter switches to listen 443 ssl when the Caddyfile uses tls. server_name carries the site address from the Caddyfile header so nginx routes the right virtual host. root maps Caddyfile root plus the file_server matcher to the directory nginx serves static files from. try_files replaces file_server by attempting the requested URI then falling back to 404, mirroring Caddy static behaviour. proxy_pass implements reverse_proxy, forwarding matched requests to the backend host or upstream pool. upstream groups several reverse_proxy targets so nginx can load balance across them. proxy_set_header re-establishes Host and the X-Forwarded-* chain that Caddy added automatically. ssl (listen 443 ssl) preserves the TLS intent from Caddy tls, with a reminder to supply certificate paths. Together they shape how the server behaves, and the tool assembles them in the right context so the result is valid on the first try.

Common mistakes are easy to make. Caddy obtains certificates automatically, but nginx needs explicit ssl_certificate and ssl_certificate_key, so the converter flags this instead of inventing invalid paths. Caddy matchers are more expressive than nginx location blocks; complex matchers are simplified to a default location / so review edge cases. A reverse_proxy with several backends must become an upstream block, or nginx cannot balance; the tool builds that block for you. Forgetting X-Forwarded-* headers hides the real client IP from your app, so the converter adds them on every proxy block. The generator anticipates each of these and either sets a safe default or rejects the input with a clear message before anything is written to your clipboard.

Validation is strict because small configuration errors fail in subtle ways. Every input is checked for plausibility, and after the block is assembled it is re-parsed by a built-in tokenizer so unbalanced braces, missing semicolons or stray characters cannot reach your clipboard. Stat cards report line and block counts, and copy, download and print exports are one click away. Everything runs in your browser; nothing you type is transmitted to any server.

In practice this block drops into any standard nginx install. Save the output as a file under /etc/nginx/conf.d/ (or sites-available with a symlink), run nginx -t to confirm the syntax, then reload with nginx -s reload. Because the generator emits a single, self-contained server block with no hidden dependencies, it composes cleanly with your existing caching, logging and security configuration without directive collisions.

Beyond producing correct config, the tool is a reference you can read back and learn from. Each control maps to a real nginx directive, the sample button shows a complete working block in seconds, and clearing the form resets every field to its safe default. Standardising on a generator like this removes per-developer variation, keeps your configuration readable, and gives you a repeatable, auditable setup that passes nginx -t on the first try.

When something looks wrong in production, the first move is always to re-run nginx -t and inspect /var/log/nginx/error.log; most failures surface there with a line number. The access log records every request, so a sudden spike or a wall of 499 responses points straight at backend or timeout problems the generator helps you avoid in the first place.

This server block is designed to sit alongside - not fight - your other configuration. Because it declares its own server_name and a single, self-contained set of directives, you can drop it into conf.d without worrying about collisions with global caching, logging or security snippets that live elsewhere in the nginx tree.

For a production site, pair this block with TLS termination: serve on 80 for the redirect or health checks, and place the encrypted listener (or a front-end load balancer / CDN) in front so clients always speak HTTPS. The generator keeps that boundary clean so the two layers compose instead of overlapping.

If a change ever needs to be undone, the output is plain text you control: delete the file from conf.d, re-run nginx -t, and reload. There is no database and no hidden state, so rolling back is as simple as restoring the previous version from version control or your own backup.

Features

  • listen - opens the port nginx serves on; the converter switches to listen 443 ssl when the Caddyfile uses tls.
  • server_name - carries the site address from the Caddyfile header so nginx routes the right virtual host.
  • root - maps Caddyfile root plus the file_server matcher to the directory nginx serves static files from.
  • try_files - replaces file_server by attempting the requested URI then falling back to 404, mirroring Caddy static behaviour.
  • proxy_pass - implements reverse_proxy, forwarding matched requests to the backend host or upstream pool.
  • upstream - groups several reverse_proxy targets so nginx can load balance across them.
  • proxy_set_header - re-establishes Host and the X-Forwarded-* chain that Caddy added automatically.
  • ssl (listen 443 ssl) - preserves the TLS intent from Caddy tls, with a reminder to supply certificate paths.
  • Self-verifying output re-parsed before display.
  • Copy, Download and Print exports.
  • Load-sample button fills realistic values.
  • Statistics cards for quick checks.
  • Runs entirely in your browser - nothing uploaded.

How to Use

  1. Paste your Caddyfile into the textarea.
  2. Click Convert (or Load sample to see a worked example).
  3. Review the generated nginx server block in the preview.
  4. Note the TLS reminder and add your real certificate paths if tls was used.
  5. Copy or download the .conf, or grab the JSON view of the parsed sites.
  6. Drop the file into conf.d, run nginx -t, then reload.
  7. Compare the output against your original Caddyfile to confirm every site was converted.

Examples

Example 1 - Single reverse proxy one backend, plain HTTP listener, proxy headers added - the most common Caddy reverse_proxy case.

Example 2 - Static file server root plus file_server becomes root and a try_files location serving files from disk.

Example 3 - TLS site a Caddyfile using tls yields listen 443 ssl with a reminder to add certificate paths.

Example 4 - Multiple backends several reverse_proxy targets become an upstream pool with round-robin proxy_pass.

Example 5 - Empty input rejected converting with an empty textarea returns a clear error instead of producing a blank block.

Benefits

  • Correct nginx server block from a Caddyfile in seconds.
  • Reverse proxy, static and TLS intents all preserved.
  • Multiple backends converted into a real upstream block.
  • X-Forwarded-* headers re-added automatically.
  • Self-checked output re-parsed before display.
  • Export as .conf or as JSON; everything stays in your browser.

Frequently Asked Questions

What does the converter handle?
It translates Caddy site blocks into nginx server blocks, preserving reverse_proxy, root/file_server static serving, and tls directives.
How is TLS handled?
When Caddy uses tls, the converter emits listen 443 ssl and a reminder to add your own ssl_certificate and ssl_certificate_key, since Caddy manages those automatically.
Are multiple backends supported?
Yes - several reverse_proxy targets become an nginx upstream block referenced by proxy_pass with round-robin balancing.
What about static sites?
A Caddyfile using root plus file_server becomes an nginx root directive with a try_files location that serves files and returns 404 when missing.
Does it rewrite Caddy matchers?
Simple path-based matchers are mapped to nginx location blocks where possible; complex matcher expressions are simplified to a default location /.
Is the output validated?
Yes - the generated config is re-parsed by a built-in tokenizer before display so unbalanced braces cannot slip through.
Can I export the result?
You can copy, download the .conf, or download a JSON view of the parsed sites, all from the actions row.
Is anything uploaded?
No. Everything runs locally in your browser; your Caddyfile never leaves the page.