常用配置
https://caddyserver.com/docs/caddyfile
域名会默认开启https,ip不会
静态目录
caddyfilelocalhost
encode zstd gzip # 开启压缩
templates # 开启模板
file_server browse # 静态服务
单页应用
caddyfileexample.com {
root * /path/to/site
encode gzip
try_files {path} /index.html
file_server
}
单页应用 + 接口转发
caddyfileexample.com {
encode gzip
handle /api/* {
reverse_proxy backend:8000
}
handle {
root * /path/to/site
try_files {path} /index.html
file_server
}
}