官网:https://caddyserver.com/docs/
Github地址:https://github.com/caddyserver/caddy
Docker部署
docker run -d --restart=always --privileged --net=host -v /data/caddy/data:/data -v /data/caddy/config/Caddyfile:/etc/caddy/Caddyfile -v /data/caddy/config/vhosts:/etc/caddy/vhosts -v /data/caddy/logs:/logs caddy:latest
先准备Caddyfile配置文件
data目录可放静态资源文件
vhosts目录放各站点的配置文件和ssl证书文件
logs目录放caddy日志文件
只需一个邮箱可自动申请并配置https访问
自用整理的Caddyfile配置文件,Caddyfile语法可参考官网教程
Caddyfile
日志
(LOG) {
log {
format json {
time_local
time_format wall_milli
}
output file "/logs/{args.0}/access.log" {
roll_size 100mb
roll_local_time
roll_keep 3
roll_keep_for 30d
}
}
}
(GZIP) {
encode zstd gzip
}
import ./vhosts/*.conf
本站反代配置示例
https://host {
import GZIP
import LOG "host"
tls /etc/caddy/vhosts/host.pem /etc/caddy/vhosts/host.key
reverse_proxy XXXXX:XX
}
自动申请ssl证书配置示例
https://域名 {
import GZIP
import LOG "域名"
tls 邮箱
reverse_proxy XXXXX:XX
}