2015-01-13 15:24:43 -05:00
Meet caddy
===========
2015-01-13 17:45:08 -05:00
Caddy is a web server for your files like Apache, nginx, or lighttpd, but with different goals, features, and advantages.
2015-01-13 15:24:43 -05:00
2015-01-21 21:16:31 -05:00
*Note:* This software is pre-1.0. Don't use it in production (yet).
2015-01-13 15:24:43 -05:00
2015-01-21 21:16:31 -05:00
### Features
- SSL (TLS)
- Gzip
- FastCGI (yes, it can serve PHP sites)
- Logging
- Rewrite
- Redirect
- Extensionless (clean) URLs
- Multi-core
- Custom headers
2015-01-13 15:24:43 -05:00
2015-01-21 21:16:31 -05:00
Caddy is designed to be super-easy to use and configure.
### Run Caddy
2015-01-13 15:24:43 -05:00
2015-01-21 21:16:31 -05:00
1. Download or build it
2015-01-13 17:45:08 -05:00
2. `cd` into a directory you want to serve
2015-01-21 21:16:31 -05:00
3. `./caddy`
2015-01-13 15:24:43 -05:00
2015-01-21 21:16:31 -05:00
Caddy will, by default, serve the current working directory on [http://localhost:8080 ](http://localhost:8080 ) (the default port will change before version 1.0).
2015-01-13 15:24:43 -05:00
### Configuring Caddy
2015-01-19 19:13:00 -05:00
If the current directory has a file called `Caddyfile` , it will be loaded and parsed and used as configuration. To configure Caddy, use a Caddyfile.
2015-01-13 15:24:43 -05:00
2015-01-13 17:45:08 -05:00
A Caddyfile always starts with the address to bind to. The rest of the lines are configuration directives. Here's an example:
2015-01-13 15:24:43 -05:00
```
mydomain.com:80
gzip
ext .html
header /api Access-Control-Allow-Origin *
```
2015-01-19 19:13:00 -05:00
This simple file enables gzip compression, serves clean URLs (tries `.html` files under the hood), and adds the coveted `Access-Control-Allow-Origin: *` header to all requests starting with `/api` . Wow! Caddy can do a lot with just four lines.
2015-01-13 15:24:43 -05:00
2015-01-13 17:45:08 -05:00
Maybe you want to serve both HTTP and HTTPS. You can define multiple (virtual) hosts using curly braces:
2015-01-13 15:24:43 -05:00
```
mydomain.com:80 {
gzip
ext .html
header /api Access-Control-Allow-Origin *
}
mydomain.com:443 {
tls cert.pem key.pem
}
```
2015-01-19 19:13:00 -05:00
For more details, including which directives you can use to configure Caddy, see [the wiki ](https://github.com/mholt/caddy/wiki ).
2015-01-13 17:45:08 -05:00
2015-01-19 19:13:00 -05:00
Better documentation (and rigorous tests) are on their way as the program matures and leaves the experimental phase.
2015-01-13 17:45:08 -05:00
2015-01-13 15:24:43 -05:00
### Contributing
2015-01-13 17:45:08 -05:00
Please submit your ideas in an issue or you can drop a quick [tweet to @mholt6 ](https://twitter.com/mholt6 ). Pull requests that fix bugs are totally welcome, too. (Pull requests for new features should be discussed in an issue first.) Thanks for being involved!