使用Docker部署Caddy
docker-compose.yml
|
|
|
|
注意一点 /data/caddy/Caddyfile 需要提前创建好
Caddyfile
Caddy有两种配置格式:1. json 2. Caddyfile,由于Caddyfile较为简洁,因此选用了这种方式。
Example
localhost
respond "Hello, world!"
静态内容
your_domain {
root * /var/www
file_server
}
反向代理
your_domain {
reverse_proxy your_server_ip:port
}
Compare
以下是Json格式和Caddyfile格式的区别:
JSON | Caddyfile |
---|---|
Full range of Caddy functionality | Most common parts of Caddy functionality |
Easy to generate | Easy to craft by hand |
Easily programmable | Difficult to automate |
Extremely expressive | Moderately expressive |
Allows config traversal | Cannot traverse within Caddyfile |
Partial config changes | Whole config changes only |
Can be exported | Cannot be exported |
Compatible with all API endpoints | Compatible with some API endpoints |
Documentation generated automatically | Documentation is hand-written |
Ubiquitous | Niche |
More efficient | More computational |
Kind of boring | Kind of fun |
Learn more: JSON structure | Learn more: Caddyfile docs |
- 原文作者:ZemelLing
- 原文链接:https://www.zling.site/post/%E4%BD%BF%E7%94%A8Docker%E9%83%A8%E7%BD%B2Caddy/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。