This page is about Caddy 2, which is currently in beta. Click here for the old Caddy 1 site. Thank you for your patience as we transition!
Documentation
Caddy 2 is beta software. It is ready for production, but some things will change between releases; check the release notes before upgrading.

Caddyfile quick-start

Create a new text file named Caddyfile (no extension).

The first thing to type in a Caddyfile is your site's address:

localhost

Then hit enter and type what you want it to do, so it looks like this:

localhost

respond "Hello, world!"

Save this and run Caddy from the same folder that contains your Caddyfile:

caddy start

Either open your browser to localhost:2015 or curl it:

curl localhost:2015
Hello, world!

You can define multiple sites in a Caddyfile by wrapping them in curly braces { }. Change your Caddyfile to be:

localhost {
	respond "Hello, world!"
}

localhost:2016 {
	respond "Goodbye, world!"
}

You can give Caddy the updated configuration two ways, either with the API directly:

curl localhost:2019/load \
  -X POST \
  -H "Content-Type: text/caddyfile" \
  --data-binary @Caddyfile

or with the reload command, which does the same API request for you:

caddy reload

Try out your new "goodbye" endpoint in your browser or with curl to make sure it works:

curl localhost:2016
Goodbye, world!

When you are done with Caddy, make sure to stop it:

caddy stop

Further reading