playbooks/roles/vhosts/caddy/templates/Caddyfile.j2
2026-04-12 18:14:28 +08:00

89 lines
1.3 KiB
Django/Jinja
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
# debug
}
import /etc/caddy/conf.d/*.caddy
############################
# portal.onwalk.net
# Next.js yarn dev
############################
{{ caddy_portal_domains | join(', ') }} {
# dev 阶段:禁止浏览器缓存
header {
Cache-Control "no-store"
}
# health check
@health {
path /health
}
handle @health {
respond 200
}
# 所有请求 → Next.js dev server
handle {
reverse_proxy {{ caddy_portal_proxy }} {
# WebSocket / HMR 必需
header_up Connection {>Connection}
header_up Upgrade {>Upgrade}
transport http {
read_timeout 0
}
}
}
}
############################
# dl.onwalk.net
# 静态下载站
############################
{{ caddy_download_domain }} {
root * {{ caddy_download_root }}
# 禁止访问 dotfiles
@dotfiles {
path_regexp hidden (^|/)\.
}
handle @dotfiles {
respond 403
}
# well-known 直出
@wellknown {
path /.well-known/*
}
handle @wellknown {
file_server
}
# JSON 文件(轻缓存)
@json {
path *.json
}
handle @json {
header {
Content-Type application/json
Cache-Control "public, max-age=60"
}
file_server
}
# 大文件(允许 Range
@bigfiles {
path *.dmg *.zip *.tar.gz *.deb *.rpm *.exe *.pkg *.appimage *.apk *.ipa
}
handle @bigfiles {
file_server
}
# 默认:目录浏览
handle {
file_server browse
}
}