2026-01-24
技术
0
Caddyfile
it.lab-terminal.tech { # Blog handle /blog/* { uri strip_prefix /blog reverse_proxy localhost:8081 } # ntfy handle /notify/* { uri strip_prefix /notify reverse_proxy localhost:8082 } # APRS API handle /aprs/* { uri strip_prefix /aprs reverse_proxy localhost:8000 } # Trilium handle / { reverse_proxy localhost:8080 } }

Caddy 的 handle 指令是 按顺序匹配 的。一旦某个 handle 块匹配成功,后续的 handle 就不会再被检查。 而 / 路径会匹配 所有请求(因为所有 URL 都以 / 开头),所以: 当用户访问 https://it.lab-terminal.tech/blog/hello 第一个 handle / 就匹配成功了 ✅ 请求直接被转发到 localhost:8080(Trilium) 后面的 /blog/、/notify/ 等规则 完全不会生效!

✅ 正确顺序:具体路径在前,兜底路径(/)在最后

本文作者:Maxwell

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC 4.0 许可协议。转载请注明出处!