指南
Caddy 是一款基于 Go 语言编写的强大且可扩展的平台,可以给你的站点、服务和应用程序提供服务。
场景
使用 API 配置 Caddy
参考官方文档:https://caddyserver.com/docs/quick-starts/api
列出目录文件
file_server browse
指定反代目录
在实践中,我们可能只想对 API 请求使用反 向代理,即基本路径为/api/
file_server
reverse_proxy /api/* 127.0.0.1:9005
故障排除
参数
路径
Caddy 配置文件:/etc/caddy/Caddyfile
命令行
$ caddy help
usage:
caddy <command> [<args...>]
commands:
adapt Adapts a configuration to Caddy's native JSON
add-package Adds Caddy packages (EXPERIMENTAL)
build-info Prints information about this build
environ Prints the environment
file-server Spins up a production-ready file server
fmt Formats a Caddyfile
hash-password Hashes a password and writes base64
help Shows help for a Caddy subcommand
list-modules Lists the installed Caddy modules
reload Changes the config of the running Caddy instance
remove-package Removes Caddy packages (EXPERIMENTAL)
reverse-proxy A quick and production-ready reverse proxy
run Starts the Caddy process and blocks indefinitely
start Starts the Caddy process in the background and then returns
stop Gracefully stops a started Caddy process
trust Installs a CA certificate into local trust stores
untrust Untrusts a locally-trusted CA certificate
upgrade Upgrade Caddy (EXPERIMENTAL)
validate Tests whether a configuration file is valid
version Prints the version