1.4 KiB
1.4 KiB
title, created, updated, type, tags, sources
| title | created | updated | type | tags | sources |
|---|---|---|---|---|---|
| Caddy Web Server | 2025-04-15 | 2026-05-01 | concept |
Caddy Web Server
现代化的 Go 语言 Web 服务器/反向代理,以自动 HTTPS 和简洁 Caddyfile 配置著称。
核心特性
- 自动 HTTPS: 无需额外配置即可自动获取和续期 Let's Encrypt 证书
- Caddyfile: 简洁直观的配置语法,远优于 Nginx 的复杂配置
- 命名匹配器 (Named Matcher):
@name { conditions... }定义可复用的请求匹配规则 - 原生反向代理:
reverse_proxy指令内置健康检查、负载均衡 - API 控制: 支持运行时通过 REST API 动态修改配置
关键指令
| 指令 | 功能 |
|---|---|
reverse_proxy |
反向代理到后端 |
header |
请求头匹配器 |
respond |
直接返回 HTTP 响应 |
route / handle |
路径级别的路由控制 |
basicauth |
HTTP Basic 认证 |
forward_auth |
委托外部认证 |
常见使用场景
- reverse-proxy-authentication — 在 Caddy 层拦截未认证请求
- forward-authentication — 复杂认证逻辑交给外部服务
- api-key-authentication — 统一 API Key 校验入口
相关概念
- caddy-reverse-proxy-auth — 反向代理认证完整方案
- reverse-proxy-authentication — 认证模式