Appearance
caddy 简单配置示例
1. Caddyfile 配置
text
example.com {
root * /rootdir # 根目录
header {
# 替换
<field> <find> <replace>
# 添加 or 设置
[+]<field> <value>
# 删除
-<field>
}
file_server # 启用文件系统
reverse_proxy /api/* localhost:8080 { # 代理其他服务
header_up Some-Header "the value" # 设置一个请求头,覆盖任何现有的值。
header_up -Some-Header # 删除一个请求头,防止它到达后端。
header_up -Some-* # 删除所有匹配的请求,使用后缀匹配。
header_down +Some-Header "first value" # 添加一个响应头
}
php_fastcgi 0.0.0.0:9000 # 代理PHP简洁写法
php_fastcgi [<matcher>] <php-fpm_gateways...> { # 代理PHP完整写法
root <path> # 设置网站的根文件夹。默认:[root指令]
split <substrings...>
env [<key> <value>]
index <filename>|off # 指定文件名作为目录索引文件。这影响到扩展形式中的文件匹配器。默认:index.php。可以设置为off,当没有找到匹配的文件时,禁止重写到index.php。
try_files <files...> # 默认:{path} {path}/index.php index.php
resolve_root_symlink
dial_timeout <duration>
read_timeout <duration>
write_timeout <duration>
... 可以使用reverse_proxy的任何子指令来定制它。
}
}