caddy/README.md

74 lines
2.4 KiB
Markdown
Raw Normal View History

2015-01-14 04:24:43 +08:00
Meet caddy
===========
2015-01-14 06:45:08 +08:00
Caddy is a web server for your files like Apache, nginx, or lighttpd, but with different goals, features, and advantages.
2015-01-14 04:24:43 +08:00
2015-01-22 10:16:31 +08:00
*Note:* This software is pre-1.0. Don't use it in production (yet).
2015-01-14 04:24:43 +08:00
2015-01-22 10:16:31 +08:00
### Features
2015-03-04 02:14:36 +08:00
- TLS
- FastCGI (mostly for PHP sites)
- WebSockets
- IPv4 and IPv6 support
2015-01-22 10:16:31 +08:00
- Gzip
2015-03-04 02:14:36 +08:00
- Custom headers
2015-01-22 10:16:31 +08:00
- Logging
2015-03-04 02:14:36 +08:00
- Rewrites
- Redirects
2015-01-22 10:16:31 +08:00
- Multi-core
2015-03-04 02:14:36 +08:00
- + more
2015-01-14 04:24:43 +08:00
2015-01-22 10:16:31 +08:00
Caddy is designed to be super-easy to use and configure.
### Run Caddy
2015-01-14 04:24:43 +08:00
2015-01-22 10:16:31 +08:00
1. Download or build it
2015-01-14 06:45:08 +08:00
2. `cd` into a directory you want to serve
2015-01-22 10:16:31 +08:00
3. `./caddy`
2015-01-14 04:24:43 +08:00
2015-01-22 10:16:31 +08: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-14 04:24:43 +08:00
### Configuring Caddy
2015-03-04 02:14:36 +08:00
Use a Caddyfile to configure Caddy. If the current directory has a file called `Caddyfile`, it will be loaded and parsed and used as configuration.
2015-01-14 04:24:43 +08:00
2015-03-04 02:14:36 +08:00
A Caddyfile always starts with an address to bind to. The rest of the lines are configuration directives. Here's an example:
2015-01-14 04:24:43 +08:00
```
mydomain.com:80
gzip
ext .html
header /api Access-Control-Allow-Origin *
```
2015-03-04 02:14:36 +08:00
This simple file enables gzip compression, serves clean URLs, 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-14 04:24:43 +08:00
2015-01-14 06:45:08 +08:00
Maybe you want to serve both HTTP and HTTPS. You can define multiple (virtual) hosts using curly braces:
2015-01-14 04:24:43 +08:00
```
mydomain.com:80 {
gzip
ext .html
header /api Access-Control-Allow-Origin *
}
mydomain.com:443 {
tls cert.pem key.pem
}
```
2015-01-20 08:13:00 +08:00
For more details, including which directives you can use to configure Caddy, see [the wiki](https://github.com/mholt/caddy/wiki).
2015-01-14 06:45:08 +08:00
2015-01-20 08:13:00 +08:00
Better documentation (and rigorous tests) are on their way as the program matures and leaves the experimental phase.
2015-01-14 06:45:08 +08:00
2015-01-14 04:24:43 +08:00
### Contributing
2015-03-04 02:14:36 +08:00
Please get involved! Before adding a new feature or changing existing behavior, open an issue to discuss it. For other non-breaking changes and bug fixes, pull requests are accepted. You can also drop a quick [tweet to @mholt6](https://twitter.com/mholt6) for quick feedback or comments.
### About the project
Caddy was born out of the need for a lightweight but configurable web server that didn't have to be "installed" and was readily available for any platform. Caddy took some inspiration from nginx, lighttpd, Websocketd, and Vagrant, and provides a pleasant mixture of the handy features from each of them. Caddy is suitable for use in both dev and production environments.