You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

887 B

Caddy 配置示例

概述

Caddy 用于反向代理和静态文件服务,自动 TLS。适用于个人工具站的部署。

示例 1: 反向代理到 Go 后端 (API + 静态)

example.com {
    reverse_proxy localhost:8080
}
  • Go 应用监听 8080,提供 API 和静态文件。

示例 2: 静态文件服务 + API 代理

example.com {
    root * /path/to/dist
    try_files {path} {path}/ /index.html
    reverse_proxy /api/* localhost:8080
}
  • 前端静态文件由 Caddy 服务,API 请求代理到后端。

示例 3: HTTPS 重定向

example.com {
    redir https://www.example.com{uri}
}

www.example.com {
    reverse_proxy localhost:8080
}

说明

  • 使用 Caddyfile 语法,简单声明式。
  • SPA 路由:try_files 处理客户端路由。
  • TLS:Caddy 自动获取 Let's Encrypt 证书。