naiveproxy搭建全流程记录

Ryan Lv2

以此文记录一次本人在一台安装了Debian系操作系统的VPS上搭建带伪装的naiveproxy的过程。

(补充介绍)NaïveProxy使用Chrome的网络栈,所以防火墙截获的流量行为与Chrome和标准前端服务器(如Caddy、HAProxy)之间的常规HTTP/2流量是完全相同的。它还通过填充长度缓解基于长度的流量分析,通过HTTP/2中的流量复用缓解指纹识别/流量分类。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
DOMAIN=your.domain
DIR=/root/niv

# Install Go
wget -c https://dl.google.com/go/go1.21.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
echo 'export GOROOT=/usr/local/go' >> /etc/profile
echo 'export PATH=$GOROOT/bin:$PATH' >> /etc/profile
source /etc/profile

# Install certbot
apt update
sudo apt-get install certbot python3-certbot-apache

sudo certbot certonly --webroot -w /var/www/html -d $DOMAIN

mkdir $DIR 2>/dev/null
cd $DIR

ln -s /etc/letsencrypt/live/$DOMAIN/fullchain.pem 1.crt
ln -s /etc/letsencrypt/live/$DOMAIN/privkey.pem 1.key

# Compile Caddy

go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive
nano Caddyfile

对于Caddyfile,请参考下例自行修改。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
order forward_proxy before route
admin off
auto_https off
}

:443 {
#----------Change Cert file location
tls /root/niv/1.crt /root/niv/1.key {
ciphers TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
alpn h2 http/1.1
}

forward_proxy {
#----------Username and password for naive
basic_auth uname passwd
hide_ip
hide_via
probe_resistance
}

@host {
#----------your domain on this machine
host $DOMAIN
}
route @host {
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
}
#----------Redirect to this domain if not naive
reverse_proxy google.com {
header_up Host {upstream_hostport}
header_up X-Forwarded-Host {host}
}
}
}

此后可利用screen会话来运行caddy (./caddy start 即可),此时服务端就已搭建好。

客户端连接时,连接类型选择为naiveproxy或HTTPS,端口请设为443,传输协议请选择HTTP2或HTTPS。并且如果有“填充”选项也请打开。
对于不支持naive的通用客户端,有一种解决方案是使用另一客户端连接代理并暴露SOCKS或HTTP内网代理端口。或可参考 https://github.com/klzgrad/naiveproxy/releases 下载对应平台的naiveproxy专用客户端。

  • Title: naiveproxy搭建全流程记录
  • Author: Ryan
  • Created at : 2023-10-11 10:19:20
  • Updated at : 2023-10-11 10:47:53
  • Link: https://blog.eddy.moe/2023/10/11/Guides/naiveproxy搭建全流程记录/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
naiveproxy搭建全流程记录