安装caddy
pacman -S caddy
Debian安装
apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install caddy
添加 http.handlers.replace_response
模块
caddy add-package github.com/caddyserver/replace-response
检查http.handlers.replace_response
模块是否安装完成
[root@archlinux ~]# caddy list-modules | grep http.handlers.replace_response
http.handlers.replace_response
Caddy目录
[root@archlinux caddy]# tree
.
├── Caddyfile
└── conf.d
修改默认 Caddyfile
配置文件 注册 replace
指令
nano /etc/caddy/Caddyfile
{
order replace after encode
}
添加网站配置
nano /etc/caddy/conf.d/example.com
example.com {
reverse_proxy https://example.com {
header_up Host {upstream_hostport}
header_up Accept-Encoding identity
}
replace aaa bbb
}
重载caddy配置
systemctl reload caddy
参考
https://caddyserver.com/docs/caddyfile/directives/reverse_proxy