搭建 Naive Proxy
适用场景:搭建一个基于 HTTP/2 与 Chromium 网络栈的 NaiveProxy 代理服务端,客户端流量伪装为普通 HTTPS 访问。本文记录使用 sing-box 搭建的完整流程。
1. 安装 sing-box
bash <(curl -fsSL https://sing-box.app/deb-install.sh)
sudo systemctl enable sing-box
2. 生成自签证书
sing-box generate tls-keypair bing.com -m 1000
执行后会输出一份私钥和证书。你可以将输出内容分别保存到以下文件中:
vim /root/fullchain.cer
vim /root/private.key
3. 配置 sing-box
将以下内容写入 config.json:
{
"inbounds": [
{
"type": "naive",
"listen": "::",
"listen_port": 你的端口,
"users": [
{
"username": "用户名",
"password": "密码"
}
],
"tls": {
"enabled": true,
"certificate_path": "/root/fullchain.cer",
"key_path": "/root/private.key"
}
}
],
"outbounds": [
{
"type": "direct"
}
]
}
配置要点:
listen_port、username、password替换为你自己的值。certificate_path/key_path指向第 2 步生成的自签证书。- 生产环境建议改用正式证书(如 acme.sh 签发),自签证书需在客户端额外信任。
4. 重启服务
sudo systemctl restart sing-box
常用命令
启用 sudo systemctl enable sing-box
禁用 sudo systemctl disable sing-box
启动 sudo systemctl start sing-box
停止 sudo systemctl stop sing-box
强行停止 sudo systemctl kill sing-box
重启 sudo systemctl restart sing-box
查看日志 sudo journalctl -u sing-box --output cat -e
实时日志 sudo journalctl -u sing-box --output cat -f
验证与自查
sudo systemctl status sing-box显示 active(running)sudo ss -lntup | grep <你的端口>确认端口监听正常sudo ls -l /root/fullchain.cer /root/private.key确认证书文件存在且非空- 客户端用 Naive 协议(用户名/密码 + 服务端地址)连接成功,
curl ip.sb出口为服务端 IP