Started Caddyfile documentation

Matt Holt 2015-01-19 16:20:14 -07:00
parent 61b5a15477
commit 62ebeca934

48
Caddyfile.md Normal file

@ -0,0 +1,48 @@
The Caddyfile is how you configure Caddy. Generally you have one Caddyfile per website.
By default, Caddy will look for the Caddyfile in the current directory, but you can specify any other path when you launch Caddy:
```
$ caddy -conf=/path/to/Caddyfile
```
And when you do that, the Caddyfile can have any filename, but we will call it the Caddyfile in the docs.
## Structure
The Caddyfile is very easy to use. It can configure either one or multiple servers (virtual hosts).
The first line is always an address to listen on:
```
yourdomain.com:80
```
The rest of the file consists of lines with directives and parameters (arguments), for example:
```
yourdomain.com:80
gzip
ext .html
```
To configure multiple servers (virtual hosts) in the same Caddyfile, wrap the directives pertaining for each server in a curly brace block, for example:
```
yourdomain.com:80 {
redir / :443 301
}
# Curly braces can be on their own line if you prefer
yourdomain.com:443
{
gzip
ext .html
tls cert.pem key.pem
}
```
Notice that a `#` token turns the rest of the line into a comment.
In the above file, the keywords `redir`, `gzip`, `ext`, and `tls` are directives. There are others. Each directive is bound to a unique piece of middleware that wraps every request in order to satisfy the Caddyfile.