之前发了个帖子https://hostloc.com/thread-1052421-1-1.html 后来大神们都说caddy+naiveproxy才是牛逼,就四处找教程~~~发现每个教程都有点坑~~,自己总结修复了坑,希望对大家有帮助. 其实没有v2 或者trojan安全性好,但是这个教程的好处是不需要客户端
安装默认Caddy
- apt-get update && apt-get install -y wget curl 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-get update && apt-get install -y caddy
复制代码
systemctl start caddy #启动 systemctl enable caddy #添加开机自启动 systemctl restart caddy #重启 systemctl status caddy #查看状态 systemctl stop caddy #停止
安装GO
- apt-get update && apt-get install -y libnss3 git debian-keyring debian-archive-keyring apt-transport-https &&
- mkdir -p /root/src/ /usr/local/ &&
- cd /root/src/ &&
- wget https://go.dev/dl/go1.18.4.linux-amd64.tar.gz &&
- tar -zxvf go1.18.4.linux-amd64.tar.gz -C /usr/local/
复制代码
在最后添加vi /etc/profile
- export GOROOT=/usr/local/go
- export PATH=$GOROOT/bin:$PATH
复制代码
更新profile source /etc/profile
确认是否更新成功 go version 编译带forwardproxy的Caddy
- cd /root/src/ &&
- go install github.com/caddyserver/xcaddy/cmd/[email protected] &&
- ~/go/bin/xcaddy build –with github.com/caddyserver/[email protected]=github.com/klzgrad/[email protected]
- cp /usr/bin/caddy /usr/bin/caddy.bak
- rm /usr/bin/caddy
- cp caddy /usr/bin/
复制代码
确认caddy版本 /usr/bin/caddy version
编辑配置vi /etc/caddy/Caddyfile,这个所有的教程我测试都不行,后来自己捣鼓了半天
- :443, domain.com
- tls [email protected]
- route {
- forward_proxy {
- basic_auth user pass
- ports 443
- hide_ip
- hide_via
- probe_resistance www.adobe.com
- }
- root * /usr/share/caddy
- file_server
- }
复制代码
|