caddyserver / caddy
caddyserver / caddy
Caddy is an extensible server platform that uses TLS by default. Caddy 是一个可扩展的服务器平台,默认启用 TLS。
Features
功能特性
- Easy configuration with the Caddyfile: Powerful configuration with its native JSON config. 通过 Caddyfile 轻松配置: 使用原生 JSON 配置进行强大的配置管理。
- Dynamic configuration with the JSON API: Config adapters if you don’t like JSON. 通过 JSON API 进行动态配置: 如果你不喜欢 JSON,可以使用配置适配器。
- Automatic HTTPS by default: ZeroSSL and Let’s Encrypt for public names; fully-managed local CA for internal names & IPs. 默认自动 HTTPS: 为公共域名提供 ZeroSSL 和 Let’s Encrypt 支持;为内部域名和 IP 提供全托管的本地 CA。
- Production-ready: Stays up when other servers go down due to TLS/OCSP/certificate-related issues; scales to hundreds of thousands of sites. 生产环境就绪: 在其他服务器因 TLS/OCSP/证书相关问题宕机时仍能保持运行;可扩展至数十万个站点。
- Highly extensible: Modular architecture lets Caddy do anything without bloat. 高度可扩展: 模块化架构让 Caddy 在不臃肿的前提下实现任何功能。
- Written in Go: A language with higher memory safety guarantees than other servers. 使用 Go 编写: 相比其他服务器,该语言具有更高的内存安全保障。
Install
安装
The simplest, cross-platform way to get started is to download Caddy from GitHub Releases and place the executable file in your PATH. See our online documentation for other install instructions. 最简单且跨平台的入门方式是从 GitHub Releases 下载 Caddy,并将可执行文件放入你的 PATH 路径中。请参阅我们的在线文档以获取其他安装说明。
Build from source
从源码构建
Requirements: Go 1.26.0 or newer. 要求: Go 1.26.0 或更高版本。
For development:
$ git clone "https://github.com/caddyserver/caddy.git"
$ cd caddy/cmd/caddy/
$ go build
开发使用: (同上代码块)
Note: These steps will not embed proper version information. For that, please follow the instructions in the next section. 注意:这些步骤不会嵌入正确的版本信息。如需嵌入版本信息,请遵循下一节的说明。
With version information and/or plugins
包含版本信息和/或插件
Using our builder tool, xcaddy…
使用我们的构建工具 xcaddy……
$ xcaddy build
…the following steps are automated: ……以下步骤将自动完成:
-
Create a new folder:
mkdir caddy -
Change into it:
cd caddy -
Copy Caddy’s main.go into the empty folder.
-
Add imports for any custom plugins you want to add.
-
Initialize a Go module:
go mod init caddy -
(Optional) Pin Caddy version:
go get github.com/caddyserver/caddy/v2@version -
(Optional) Add plugins by adding their import:
_ "import/path/here" -
Compile:
go build -tags=nobadger,nomysql,nopgx -
创建新文件夹:
mkdir caddy -
进入文件夹:
cd caddy -
将 Caddy 的 main.go 复制到该空文件夹中。
-
为你想要添加的任何自定义插件添加导入语句。
-
初始化 Go 模块:
go mod init caddy -
(可选)锁定 Caddy 版本:
go get github.com/caddyserver/caddy/v2@version -
(可选)通过添加导入语句来添加插件:
_ "import/path/here" -
编译:
go build -tags=nobadger,nomysql,nopgx
Quick start
快速入门
The Caddy website has documentation that includes tutorials, quick-start guides, reference, and more. We recommend that all users — regardless of experience level — do our Getting Started guide to become familiar with using Caddy. Caddy 网站提供了包含教程、快速入门指南、参考手册等在内的文档。我们建议所有用户(无论经验水平如何)都阅读我们的“入门指南”,以熟悉 Caddy 的使用。
Overview
概览
Caddy is most often used as an HTTPS server, but it is suitable for any long-running Go program. First and foremost, it is a platform to run Go applications. Caddy “apps” are just Go programs that are implemented as Caddy modules. Caddy 最常被用作 HTTPS 服务器,但它适用于任何长期运行的 Go 程序。首先,它是一个运行 Go 应用程序的平台。Caddy 的“应用”本质上就是作为 Caddy 模块实现的 Go 程序。
Full documentation
完整文档
Our website has complete documentation: https://caddyserver.com/docs/ 我们的网站提供完整文档:https://caddyserver.com/docs/
Getting help
获取帮助
We advise companies using Caddy to secure a support contract through Ardan Labs before help is needed. A sponsorship goes a long way! 我们建议使用 Caddy 的公司在需要帮助之前,通过 Ardan Labs 签订支持合同。赞助对项目的发展大有裨益!