Youtube视频
配置文件结构
/naiveproxy/ tree
.
├── config
│ └── Caddyfile
├── docker-compose.yml
├── Dockerfile
└── README.md
1 directory, 4 files
使用说明
- 需要先自行安装好
docker
以及docker compose
,并运行docker
解压文件
unzip naiveproxy.zip
进入到解压目录
cd naiveproxy
编辑
Caddyfile
配置文件(小白专用),懂编辑器也可以用编辑器自行修改配置文件# 请先将域名解析到自己的服务器 # xxx.xxx.xxx 请修改为自己的域名 sed -i 's/#domain#/xxx.xxx.xxx/g' config/Caddyfile # 修改申请SSL证书使用的邮箱,xxx@xxx.xxx修改为自己的邮箱地址,建议使用自己的邮箱 sed -i 's/#email#/xxx@xxx.xxx/g' config/Caddyfile # 修改认证账号,请将"test test"改为自己的账号密码,用户名和密码需要空格隔开 sed -i 's/#account#/test test/g' config/Caddyfile
运行
docker compose up -d
- 日志文件映射在
./logs
下
配置文件
Caddyfile
(LOG) {
log {
output file /var/log/caddy/access.log {
roll_size 10mb
roll_keep 30
rool_keep_for 30d
}
format filter {
wrap json {
time_format "wall"
time_key "time"
time_local
}
fields {
user_id delete
duration delete
resp_headers delete
status delete
request>uri delete
request>remote_port delete
request>tls delete
request>method delete
request>headers>User-Agent delete
request>headers>Accept-Encoding delete
request>headers>Padding delete
}
}
level INFO
}
}
{
order forward_proxy before reverse_proxy
servers {
log_credentials
}
}
:443, #domain# {
tls #email#
import LOG
forward_proxy {
basic_auth #account#
hide_ip
hide_via
probe_resistance
}
reverse_proxy https://github.com {
header_up Host {upstream_hostport}
}
}
Dockerfile
FROM golang:1.20-alpine as build
RUN mkdir /naiveproxy
WORKDIR /naiveproxy
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
RUN xcaddy build v2.6.4 --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive
FROM alpine:latest as run
COPY --from=build /naiveproxy/caddy /usr/local/bin/caddy
EXPOSE 80 443
CMD ["/usr/local/bin/caddy", "run", "--environ", "--config", "/etc/caddy/Caddyfile"]
docker-compose.yml
version: "3"
services:
naiveproxy:
build:
context: .
target: run
container_name: naive
ports:
- "80:80"
- "443:443"
volumes:
- ./config:/etc/caddy/
- ./logs:/var/log/caddy/
restart: always