去 caddy2 官方 github 下载和 Linux 系统对应的可执行文件 https://github.com/caddyserver/caddy/releases 尽可能下载最新的版本,因为 bug 少,下载完成后并移动到 /usr/bin/ 下 (如果你有能力也可以下载源码进行编译安装)
- 第一种:
{
experimental_http3
}
yourdomain.com {
root * /var/www/html
file_server
encode zstd gzip
tls /root/.acme.sh/yourdomain.com/fullchain.cer /root/.acme.sh/yourdomain.com/yourdomain.com.key
reverse_proxy /ss localhost:10808
}
第一种方式还需要在 v2ray-plugin 的 plugin_opts 中填写 path=/ss
- 第二种方式
{
experimental_http3
}
yourdomain.com {
root * /var/www/html
file_server
encode zstd gzip
tls /root/.acme.sh/yourdomain.com/fullchain.cer /root/.acme.sh/yourdomain.com/yourdomain.com.key
route /ss* {
uri strip_prefix /ss
reverse_proxy localhost:10808
}
}
第二种方式不需要在 v2ray-plugin 的 plugin_opts 中填写 path=/ss
我原来用的就是ss + v2ray-plugin 的形式,所以这里 caddy tls 我直接使用原来 acme 脚本申请的 cf 证书;并且对网站设置支持 http3 访问.
{
"server": "0.0.0.0",
"nameserver": "1.1.1.1",
"server_port": 10808,
"password": "password",
"method": "chacha20-ietf-poly1305",
"timeout": 400,
"no_delay": true,
"reuse_port": true,
"workers": 1,
"mode": "tcp_and_udp",
"plugin": "/usr/bin/v2ray-plugin",
"plugin_opts": "server;host=yourdomian.xom;loglevel=none;path=/ss"
}
tls;host=yourdomain.com;path=/ss
caddy start --config /root/Caddyfile