
0. Preparation
0.1 Open Ports on Ubuntu
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F
0.2 Remove the Firewall
apt-get purge netfilter-persistent
apt-get remove ufw
reboot
0.3 Add an A Record for the Domain and Point It to the Server IPv4 Address
Cloudflare users should mainly disable DNS proxying.
Ping your domain name. If it returns your server IP address, it is fine.
For example: a.xyz.com
The following commands need to be run as the root user.
1. Install Go
1.1 Download Go for X86-X64
wget "https://dl.google.com/go/$(curl -s https://go.dev/VERSION?m=text | grep -o 'go[0-9\.]*'
).linux-amd64.tar.gz"
tar -xf go*.linux-amd64.tar.gz -C /usr/local/
1.2 Download Go for ARM
wget "https://dl.google.com/go/$(curl -s https://go.dev/VERSION?m=text | grep -o 'go[0-9\.]*'
).linux-arm64.tar.gz"
tar -xf go*.linux-arm64.tar.gz -C /usr/local/
1.3 Enable Go for X86-X64 and ARM
echo 'export GOROOT=/usr/local/go' >> /etc/profile
echo 'export PATH=$GOROOT/bin:$PATH' >> /etc/profile
source /etc/profile
1.4 Check Whether Go Was Installed Successfully
go version

If you see this, the installation succeeded.
2. Install the NaiveProxy Server Side, Caddy
2.1 Install Caddy
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
2.2 Install Naive
~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive
This step takes some time.
2.3 Copy the Caddy File to /usr/bin
cp caddy /usr/bin/
/usr/bin/caddy version
2.4 Use setcap So /usr/bin/caddy Can Start Ports Below 1024 Without the Root User
setcap cap_net_bind_service=+ep /usr/bin/caddy
2.5 Clear Additional Permissions
setcap -r /usr/bin/caddy
3. Enable BBR
bash -c 'echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf'
bash -c 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf'
sysctl -p
4. Configure Caddy
4.1 Modify the Caddyfile
mkdir /etc/caddy/
vi /etc/caddy/Caddyfile
Enter the following information:
:443, example.com
tls youremail@example.com
route {
forward_proxy {
basic_auth yourname pass
hide_ip
hide_via
probe_resistance
}
file_server {
root /var/www/html
}
}
Change example.com to your own domain, such as a.xyz.com.
Change yourname to your username.
Change pass to your password.
4.2 Add a Website
mkdir /var/www
mkdir /var/www/html
cd /var/www/html
touch index.html
vi index.html
Add the following content:
<H2>Hello, World!To the world!!<H2>
The content can be anything.
Save and exit.
5. Start Caddy
5.1 Format the Configuration File
caddy fmt --overwrite /etc/caddy/Caddyfile
5.2 Start with the Configuration File
caddy run --config /etc/caddy/Caddyfile
6. Create a Service Auto-Start File
vi /etc/systemd/system/naive.service
Paste the following content:
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
Type=notify
User=root
Group=root
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
7. Start the Service and Enable Auto-Start on Boot
systemctl daemon-reload
systemctl enable naive
systemctl start naive
systemctl status naive
The server-side configuration is now complete.
Configure the Client Configuration File
{
"listen": "socks://127.0.0.1:1080",
"proxy": "https://user:pass@example.com",
"log": ""
}
Modify user, pass, and example according to what you entered earlier.



