|
前一阵子,薅gcp羊毛后,采用了甬哥的一键脚本,生成了tuic v5类型的节点,
尝试了一下,速度比我的reality节点更快。
今天上午闲的没事,用和舍友合租的dmit 50刀的优化线路搭建了一个tuic v5的节点。搭建过程如下:
首先便是安装sing-box,debian系统的安装命令如下:
# 下载 sing-box 的 GPG 密钥并保存到 /etc/apt/keyrings/sagernet.asc
sudo curl -fsSL https://sing-box.app/gpg.key -o /etc/apt/keyrings/sagernet.asc
# 设置 sagernet.asc 文件的权限为所有用户可读
sudo chmod a+r /etc/apt/keyrings/sagernet.asc
# 添加 Sagernet 的软件源信息到 /etc/apt/sources.list.d/sagernet.list
echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/sagernet.asc] https://deb.sagernet.org/ * *" | \
sudo tee /etc/apt/sources.list.d/sagernet.list > /dev/null
# 更新本地的软件包列表
sudo apt-get update
# 安装 sing-box 或 sing-box-beta
sudo apt-get install sing-box # or sing-box-beta
具体可见sing-box的官方文档安装页面:https://sing-box.sagernet.org/zh/installation/package-manager/
# 编辑sing-box的配置文件
vim /etc/sing-box/config.json
# sing-box的配置文件样例,包含分流
{
"inbounds": [
{
"type": "tuic",
"tag": "tuic-in",
"listen": "::",
"listen_port": 监听的端口,
"sniff": true,
"sniff_override_destination": true,
"users": [
{
"uuid": "可以使用sing-box generate uuid生成",
"password": "密码"
}
],
"congestion_control": "bbr",
"tls": {
"enabled": true,
"alpn": [
"h3"
],
"certificate_path": "你的cf证书路径",
"key_path": "你的cf私钥路径"
}
}
],
"outbounds": [
{
"type": "shadowsocks",
"tag": "ss-out",
"server": "落地分流ip",
"server_port": 落地分流端口,
"method": "ss加密协议",
"password": "ss密码"
},
{
"type": "direct",
"tag": "direct-out"
}
],
"route": {
"rules": [
{
"rule_set": [
"geosite-openai",
"geosite-bing",
"geosite-anthropic",
"geosite-reddit"
],
"outbound": "ss-out"
}
],
"rule_set": [
{
"tag": "geosite-openai",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-openai.srs"
},
{
"tag": "geosite-bing",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-bing.srs"
},
{
"tag": "geosite-anthropic",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-anthropic.srs"
},
{
"tag": "geosite-reddit",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-reddit.srs"
}
],
"final": "direct-out"
},
"experimental": {
"cache_file": {
"enabled": true
}
}
}
注意点:其中证书和私钥通过cloudflare的某个域名如example.com的original server选项卡生成的。
# 设置sing-box开机自启,并立马启动sing-box
systemctl enable --now sing-box
客户端的certificate选项填写example.com的original server生成的证书,并且sni填写如tuic.example.com这类域名,不需要解析tuic.example.com到服务器ip。
在我情景下,example.com的original server选项卡生成证书时,匹配的域名有*.example.com和example.com【也就是说生成的证书是通配符证书】,所以sni填写任何example.com的前缀都是ok的。
实现TLS通信的两个前提:
![](https://cdn.sa.net/2024/06/10/hobWRU86MJqArSn.webp)
当然你也可以使用openssl生成bing的自签证书,紧接着客户端的sni填写www.bing.com,allow insecure勾选上即可。
|
|