Caddy 反向代理 + 自动 TLS
一份 Caddyfile,自动签发 Let's Encrypt 证书、HTTP/3 与合理默认值——给任何应用加 TLS 的最快路径。
Caddy 是最省心的 TLS 终结器:自动获取并续期证书,原生支持 HTTP/3。是 NoctisNode VPS 上各类应用的理想入口。
安装
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt update && apt install -y caddy单文件配置
caddy reload 零停机生效。域名一解析到服务器 IP 就会自动申请证书——NoctisNode 的 IP 很干净,ACME 校验一次通过。
# /etc/caddy/Caddyfile
example.com {
reverse_proxy 127.0.0.1:3000
encode zstd gzip
headers {
Strict-Transport-Security "max-age=63072000"
X-Content-Type-Options nosniff
}
}小技巧
- ▹若站点需在 DNS 切换前保持可达,使用 DNS-01 验证。
- ▹洋葱服务只在 clearnet 镜像侧由 Caddy 终止 TLS——onion 侧无需证书。
- ▹上游绑定 127.0.0.1,确保无法被直接访问。