前言:好久没有出现大模型质量对比测试的视频或帖子了
疑问1:为什么会有这个帖子?
答:应付如下的使用场景
使用场景:使用大模型回答超出个人的能力范围的疑问或者减低实际繁琐操作的步骤。
既然是超出了个人的能力范围,那么对于大模型的回答你就不能判断是否正确。所以一个回答正确率高大模型才是最重要的。
众所周知:大模型是基于投喂的知识库总结出的回答,那么,他的知识库更新日期和模型训练能力将决定它的实际效果。下面将以如下的提问询问各种渠道的大模型
为了保证实际体验,所有测试的模型只问一次,问题相同
问题来自 https://linux.do/t/topic/1281646
具体问题:
1
|
sing-box内核如何搭建vless+ws+cdn+tls ,使用sing-box内核编写配置文件的方式。
|
[details=“Gemini AI Pro 思考模式(3 Pro)”]
搭建 Sing-Box 内核的 VLESS + WebSocket (WS) + TLS + CDN 方案,重点在于配置文件的编写。这个组合的优势在于它可以隐藏在正常的 HTTPS 流量中,并且可以套用 Cloudflare 等 CDN 来隐藏真实 IP。
以下是详细的手动配置指南和完整的 config.json 文件结构。
1. 核心准备工作
在编写配置之前,请确保你已经准备好:
- 域名:托管在 Cloudflare(如果需要 CDN 功能)。
- 证书:域名的 SSL 证书文件(
.crt 和 .key)。推荐使用 acme.sh 或 certbot 申请免费证书。
- UUID:生成一个 UUID 作为密码(命令行输入
sing-box generate uuid 即可获得)。
2. 服务端配置文件 (Server)
在服务器上,Sing-Box 的配置文件通常位于 /etc/sing-box/config.json。
关键点说明:
- Inbounds (入站):配置
vless 协议,监听 443 端口。
- Transport (传输层):指定
ws (WebSocket),并设置 path(路径)。
- TLS:开启 TLS,并指向你的证书文件路径。
完整 config.json 示例
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
38
39
40
41
42
43
|
{
"log": {
"level": "info",
"timestamp": true
},
"inbounds": [
{
"type": "vless",
"tag": "vless-in",
"listen": "::",
"listen_port": 443,
"users": [
{
"uuid": "你的-UUID-填在这里",
"flow": ""
}
],
"tls": {
"enabled": true,
"server_name": "你的域名.com",
"certificate_path": "/path/to/your/cert.crt",
"key_path": "/path/to/your/private.key"
},
"transport": {
"type": "ws",
"path": "/yourpath",
"headers": {
"Host": "你的域名.com"
}
}
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
]
}
|
⚠️ 修改指南:
- UUID: 替换
你的-UUID-填在这里。
- server_name: 替换为你的真实域名。
- 证书路径: 修改
certificate_path 和 key_path 为你服务器上证书的实际绝对路径。
- Path:
/yourpath 是 WebSocket 的路径,可以自定义(如 /chat),客户端必须填一样的。
3. 关于 CDN (Cloudflare) 的设置
要启用 CDN(隐藏 IP):
- Cloudflare 后台:在 DNS 设置中,将你的域名记录(A 记录)的“代理状态”由 灰色云朵 改为 橙色云朵 (Proxied)。
- SSL/TLS 设置:在 Cloudflare 的 SSL/TLS 选项卡中,将加密模式设置为 Full (Strict)。
- 原因:我们的 Sing-Box 配置了真实有效的证书,所以用 Strict 模式最安全且不容易报错。
4. 客户端配置 (Client)
客户端(如 v2rayN, Nekobox, 或 Sing-Box 客户端)需要添加一个 VLESS 服务器。如果使用 Sing-Box 内核作为客户端,配置如下:
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
|
{
"outbounds": [
{
"type": "vless",
"tag": "proxy-vless",
"server": "你的域名.com",
"server_port": 443,
"uuid": "你的-UUID-填在这里",
"flow": "",
"tls": {
"enabled": true,
"server_name": "你的域名.com",
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
},
"transport": {
"type": "ws",
"path": "/yourpath",
"headers": {
"Host": "你的域名.com"
}
},
"packet_encoding": "xudp"
}
]
}
|
客户端设置重点:
- 地址 (address): 填你的域名(Cloudflare 会解析到 CDN IP,CDN 再转发给你)。
- 端口 (port): 必须是 Cloudflare 支持的 HTTPS 端口(通常是
443,也可以是 2053, 2083, 2087, 2096)。
- 传输协议: WebSocket (ws)。
- Host / SNI: 必须填写你的域名。
- Path: 必须与服务端完全一致。
5. 启动与调试
配置完成后,使用以下命令运行 Sing-Box:
1
2
3
4
5
|
# 测试配置文件是否有语法错误
sing-box check -c /etc/sing-box/config.json
# 启动服务
sing-box run -c /etc/sing-box/config.json
|
如果使用 Systemd 管理(推荐):
1
2
3
|
systemctl start sing-box
systemctl enable sing-box
systemctl status sing-box
|
常见问题排查
- Error 403/404: 通常是
path 路径不匹配,或者 Cloudflare 还没有生效(等待几分钟)。
- 握手失败 (Handshake failed): 检查服务器时间是否与标准时间同步,时间误差过大会导致 TLS 握手失败。
- 证书权限: 确保 sing-box 运行的用户有权限读取证书文件。
[/details]
[details=“Chatgpt 网页免费版”]
要在 sing-box 内核中搭建 VLESS + WS + CDN + TLS,你需要根据 sing-box 的配置文件语法来正确设置。sing-box 支持使用 JSON 格式的配置文件来配置节点和协议,下面是一个基础的配置示例,它结合了你要求的 VLESS、WebSocket (WS)、TLS 和 CDN。
1. 安装 sing-box
首先,确保你已经安装了 sing-box。你可以通过以下步骤安装:
1
2
3
|
tar -zxvf sing-box-linux-amd64.tar.gz
cd sing-box
chmod +x sing-box
|
- 启动 sing-box(需要编写配置文件,具体步骤请见下文)。
2. 配置文件示例
以下是一个包含 VLESS + WS + TLS + CDN 的 sing-box 配置文件示例(假设你正在使用 WebSocket 和 TLS):
sing-box-config.json
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
{
"inbounds": [
{
"tag": "ws-vless",
"port": 443,
"listen": "0.0.0.0",
"protocol": "vless",
"settings": {
"clients": [
{
"id": "8c56b1ff-4245-43fb-b0a4-6d658b213d1a",
"alterId": 0
}
],
"decryption": "none",
"fallbacks": [
{
"dest": 10000,
"xver": 1,
"path": "/vless",
"headers": {
"Host": "your-cdn-domain.com"
}
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/vless",
"headers": {
"Host": "your-cdn-domain.com"
}
},
"security": "tls",
"tlsSettings": {
"serverName": "your-cdn-domain.com",
"certificates": [
{
"certificateFile": "/path/to/your/fullchain.pem",
"keyFile": "/path/to/your/privatekey.pem"
}
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
}
],
"dns": {
"servers": [
"8.8.8.8",
"1.1.1.1"
]
}
}
|
配置文件说明:
- inbounds:设置服务端的入站连接。配置了
VLESS 协议,并且通过 WebSocket (WS) 搭配 TLS 和 CDN 域名(your-cdn-domain.com)。
- port:设置服务器监听的端口,一般来说 HTTPS 用 443 端口。
- protocol:设置协议为
vless。
- settings.clients.id:这是一个 UUID,表示用户的唯一标识符,客户端需要使用这个 ID。
- fallbacks:如果你想利用 CDN 的伪装功能,可以配置
fallback,并设置 path 和 headers,它们需要和 CDN 设置一致。
- streamSettings.network:设置为
ws,表示使用 WebSocket 协议。
- wsSettings.path:设置 WebSocket 路径,这里设置为
/vless。
- tlsSettings:配置 TLS,确保你已经准备好了有效的证书和私钥。
3. 配置 CDN
CDN 配置一般会依赖于你使用的具体服务,例如 Cloudflare、Alibaba Cloud 或其他 CDN 服务。你需要在 CDN 配置中设置以下内容:
- 域名:将你自定义的域名(如
your-cdn-domain.com)指向你的服务器 IP 地址。
- TLS 证书:如果你的 CDN 提供 SSL/TLS 终端,确保正确配置。
- WebSocket 协议支持:确保 CDN 支持 WebSocket 流量,并启用了适当的 WebSocket 参数。
4. 启动 sing-box
配置好文件后,运行 sing-box:
1
|
./sing-box run -c sing-box-config.json
|
5. 配置客户端
客户端的配置也需要使用 VLESS 协议,并且指定服务器的 WebSocket 地址和路径。例如:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
{
"vless": {
"server": "your-cdn-domain.com",
"port": 443,
"uuid": "8c56b1ff-4245-43fb-b0a4-6d658b213d1a",
"alterId": 0,
"security": "tls",
"network": "ws",
"wsSettings": {
"path": "/vless"
}
}
}
|
总结
- 配置
sing-box 内核时,重点是确保 VLESS 协议与 WebSocket 配合使用,并且启用了 TLS 和 CDN 域名。
- 根据 CDN 提供商的要求调整相关配置,确保 WebSocket 和 TLS 通过 CDN 正常传输。
如果你有更多具体问题,或遇到某个环节的困惑,可以告诉我,我会继续帮助你解决!
[/details]
[details=“Deepseek 网页版,开启深度思考和联网搜索”]
使用 sing-box 搭建 VLESS + WebSocket + TLS 协议并配合 CDN,需要通过配置文件实现。这通常是用于服务端的配置。
下面是一个基础的服务端配置文件示例和关键配置说明,你可以根据自己的情况修改。
📝 核心配置文件示例
创建一个 config.json 文件,写入以下内容:
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
38
39
40
41
|
{
"log": {
"level": "info"
},
"inbounds": [
{
"type": "vless",
"tag": "vless-in",
"listen": "127.0.0.1",
"listen_port": 你的内部端口号,
"sniff": true,
"sniff_override_destination": true,
"users": [
{
"uuid": "你的用户UUID",
"flow": ""
}
],
"transport": {
"type": "ws",
"path": "你的WebSocket路径,如 /ray"
},
"tls": {
"enabled": true,
"server_name": "你的域名",
"certificate_path": "你的TLS证书文件路径,如 /path/to/fullchain.cer",
"key_path": "你的TLS私钥文件路径,如 /path/to/private.key"
}
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
]
}
|
🔧 关键配置说明与修改指南
你需要修改以下配置项才能使用:
| 配置项 |
说明与示例 |
如何获取/生成 |
listen_port |
服务内部监听端口。注意:如果你使用CDN,这里通常监听本地,如 127.0.0.1:12345。 |
自定义一个未占用的端口。 |
uuid |
用户唯一标识,是客户端连接的核心凭证。 |
使用命令 sing-box generate uuid 生成。 |
transport.path |
WebSocket 路径,客户端必须匹配。 |
自定义,如 "/yourpath"。 |
tls.server_name |
你的域名,需与证书匹配。 |
你已解析到服务器的域名。 |
tls.certificate_path |
完整证书链(PEM格式)路径。 |
从证书颁发机构获取,或使用 Let‘s Encrypt 等免费申请。 |
tls.key_path |
私钥文件(PEM格式)路径。 |
与证书同时生成。 |
🌐 整合CDN(如Cloudflare)
CDN的作用是在你的服务器前提供一个“中转站”。配置要点如下:
- 修改监听地址:在配置中,
listen 建议设置为 "127.0.0.1",让服务只在本机运行。
- 使用外部Web服务器:你需要一个 Nginx 或 Caddy 这样的Web服务器,监听443端口,处理TLS握手,并将WebSocket流量转发到上面配置的
listen_port。
- CDN设置:在CDN提供商(如Cloudflare)的控制面板中:
- 将你的域名DNS解析记录指向你的服务器IP。
- 开启 Proxy (CDN) 模式(通常是云朵图标变橙色)。
- 确保CDN支持 WebSocket 协议(Cloudflare默认支持)。
🛠️ 后续步骤与测试
- 保存并启动:将修改好的配置文件(如保存为
/etc/sing-box/config.json),使用 sudo systemctl restart sing-box 启动服务。
- 配置客户端:在你的客户端(如v2rayN、Clash)中,按照以下信息配置服务器:
- 地址:你的域名
- 端口:443 (CDN端口)
- 用户ID:填写的
uuid
- 传输协议:
ws
- WebSocket路径:填写的
path
- TLS:启用
- 测试连通:使用
sudo systemctl status sing-box 查看服务状态,并通过客户端尝试连接。
⚠️ 重要提醒
- 由于使用CDN,你的真实服务器IP应对CDN提供商可见,但对外隐藏。这意味着所有流量都会经过CDN服务器。
- 证书和私钥文件路径必须正确,且sing-box进程有读取权限。
如果你想了解不使用CDN的直连配置、Reality协议(无需域名的替代方案)的配置,或者客户端的详细配置示例,我可以为你进一步介绍。
[/details]
[details=“智谱清言 网页版 GLM4.6 开启推理”]
好的,没有问题。使用 sing-box 内核搭建 VLESS + WebSocket + CDN + TLS 是目前非常流行和稳定的一种科学上网方案,它兼具了高性能和强隐蔽性。
下面我将为你提供一份详尽的、分步的指南,包括准备工作、整体架构、以及详细的服务端和客户端 sing-box 配置文件。
核心思想
这个方案的核心是“伪装”。我们将 VLESS 协议的流量包裹在 WebSocket (WS) 协议里,再通过 TLS 加密,使其看起来和普通的 HTTPS 网站流量一模一样。最后,通过 CDN(如 Cloudflare)进行中转,可以隐藏你的真实服务器 IP,并利用 CDN 的全球节点加速访问。
流量路径:
你的设备 -> sing-box客户端 -> CDN节点 (如Cloudflare) -> 你的VPS服务器 -> 目标网站
第一步:准备工作
在开始之前,你需要准备好以下几样东西:
- 一台VPS (服务器):推荐选择海外服务商,如 Vultr, DigitalOcean, BandwagonHost 等。操作系统建议选择 Ubuntu 20.04 / 22.04 或 Debian 11 / 12。
- 一个域名:可以是免费的
.tk, .ml 等,但更推荐购买一个便宜的顶级域名(如 .xyz, .top),稳定性更好。
- 一个CDN服务:Cloudflare 是最常用且免费的选择。注册一个账号即可。
- SSH客户端:用于连接和管理你的VPS,如 Xshell (Windows), Terminal (macOS/Linux)。
第二步:域名和CDN配置
这是非常关键的一步,目的是让流量能够正确地从 CDN 转发到你的服务器。
- 解析域名到VPS
- 登录你的域名服务商后台(如 GoDaddy, NameSilo)。
- 添加一条
A 记录,将一个子域名(例如 vless)指向你VPS的IP地址。
Type: A
Name: vless (或者你喜欢的任何名字)
Value: 你的VPS的IP地址
TTL: 默认即可
- 等待几分钟让解析生效。
- 配置Cloudflare
- 将你的域名添加到 Cloudflare 账户中。Cloudflare 会自动扫描你现有的 DNS 记录。
- 在 Cloudflare 的 DNS 管理页面,确保你刚才创建的
vless 子域名记录存在,并且状态是已代理(橙色云朵图标)。这是开启CDN的关键。
- 进入
SSL/TLS -> Overview 页面,将加密模式设置为 完全 (严格)。这会强制 Cloudflare 到你服务器之间的连接也必须使用有效的 TLS,安全性最高。
- (可选)进入
网络 页面,开启 0-RTT Connection Resumption 以获得更快的连接速度。
第三步:服务器端配置
现在,通过 SSH 连接到你的 VPS,开始安装和配置 sing-box。
- 下载并安装 sing-box
1
2
3
4
5
6
7
8
9
10
11
12
|
# 下载 sing-box
wget https://github.com/SagerNet/sing-box/releases/download/v1.8.11/sing-box-1.8.11-linux-amd64.tar.gz
# 解压
tar -xzf sing-box-1.8.11-linux-amd64.tar.gz
# 移动文件到系统目录
sudo mv sing-box-1.8.11-linux-amd64/sing-box /usr/local/bin/
# 赋予执行权限
sudo chmod +x /usr/local/bin/sing-box
# 创建配置目录
sudo mkdir -p /etc/sing-box
# 清理
rm -rf sing-box-1.8.11-linux-amd64*
|
- 创建服务器端配置文件
- 创建并编辑配置文件
sudo nano /etc/sing-box/config.json。
- 将以下内容粘贴进去,并仔细修改标注的部分。
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
38
39
40
41
42
43
44
45
46
47
|
{
// 日志配置
"log": {
"level": "info",
"timestamp": true
},
// 入站配置:客户端连接服务器的入口
"inbounds": [
{
"type": "vless",
"tag": "vless-in",
// 监听 IP,0.0.0.0 表示监听所有网卡
"listen": "0.0.0.0",
// 监听端口,Cloudflare CDN 只支持 80, 443, 8080, 8443, 2053, 2083, 2087, 2096, 8880。443 是最标准的。
"listen_port": 443,
"users": [
{
// 必须生成一个 UUID,不要用这个示例的
"uuid": "your-uuid-here",
// VLESS over WS/TLS 不需要 flow
}
],
"transport": {
"type": "ws",
// WebSocket 路径,可以自定义,越复杂越好,但要和客户端保持一致
"path": "/your-custom-path-that-is-hard-to-guess",
"headers": {
// Host 必须是你的域名,让 CDN 知道如何路由
"Host": "vless.yourdomain.com"
}
},
"tls": {
"enabled": true,
// 服务器证书配置,使用 Cloudflare 提供的证书
"certificate_path": "/etc/sing-box/cert.pem",
"key_path": "/etc/sing-box/key.pem"
}
}
],
// 出站配置:服务器访问互联网的出口
"outbounds": [
{
"type": "direct",
"tag": "direct"
}
]
}
|
- 申请和部署TLS证书
- 因为我们使用了 Cloudflare 的
完全 (严格) 模式,所以服务器上必须有一个有效的证书。我们可以使用 acme.sh 脚本来自动申请 Let’s Encrypt 的免费证书。
- 安装
acme.sh:
1
|
curl https://get.acme.sh | sh -s email=your-email@example.com
|
1
|
~/.acme.sh/acme.sh --issue -d vless.yourdomain.com --standalone
|
1
2
3
4
|
~/.acme.sh/acme.sh --install-cert -d vless.yourdomain.com \
--key-file /etc/sing-box/key.pem \
--fullchain-file /etc/sing-box/cert.pem \
--reloadcmd "sudo systemctl restart sing-box"
|
- 注意:申请证书时,
standalone 模式会临时占用 80 端口。请确保你的 VPS 防火墙放行了 80 和 443 端口,并且这两个端口没有被其他程序占用。
- 创建 systemd 服务并启动
- 创建服务文件
sudo nano /etc/systemd/system/sing-box.service:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[Unit]
Description=sing-box service
Documentation=https://sing-box.sagernet.org/
After=network.target nss-lookup.target
[Service]
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
ExecStart=/usr/local/bin/sing-box run -c /etc/sing-box/config.json
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=10s
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
|
1
2
3
|
sudo systemctl daemon-reload
sudo systemctl enable sing-box
sudo systemctl start sing-box
|
- 检查状态:
sudo systemctl status sing-box。如果看到 active (running),说明服务端配置成功!
第四步:客户端配置
现在,在你的本地设备(Windows, macOS, Android, iOS 等)上配置 sing-box 客户端。
- 下载对应平台的 sing-box 客户端
- 创建客户端配置文件
- 在客户端 sing-box 的目录下,创建
config.json 文件。
- 将以下内容粘贴进去,并仔细修改标注的部分。
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
{
"log": {
"level": "info",
"timestamp": true
},
// 入站配置:本地设备上接收流量的端口
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
// 监听地址,通常是本地
"listen": "0.0.0.0",
// 本地代理端口,浏览器等应用需要配置此端口
"listen_port": 1080
}
],
// 出站配置:连接到远程服务器的配置
"outbounds": [
{
"type": "vless",
"tag": "vless-out",
// 服务器地址,填你的域名,CDN会自动解析到最优节点
"server": "vless.yourdomain.com",
"server_port": 443,
"uuid": "your-uuid-here", // 必须和服务端一致
"transport": {
"type": "ws",
// WebSocket 路径,必须和服务端一致
"path": "/your-custom-path-that-is-hard-to-guess",
"headers": {
// Host 必须和服务端一致
"Host": "vless.yourdomain.com"
}
},
"tls": {
"enabled": true,
// SNI,告诉 CDN 你想访问哪个域名,通常和 server 一致
"server_name": "vless.yourdomain.com",
// uTLS 指纹伪装,可以更好地模拟浏览器,防止被识别
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
],
// 路由配置:决定哪些流量走代理,哪些直连
"routing": {
"rules": [
// 局域网IP直连
{
"geoip": "private",
"outbound": "direct"
},
// 中国大陆IP直连
{
"geoip": "cn",
"outbound": "direct"
},
// 中国大陆域名直连
{
"geosite": "cn",
"outbound": "direct"
},
// 广告域名屏蔽
{
"geosite": "category-ads-all",
"outbound": "block"
},
// 其他所有流量全部走代理
{
"inbound": "mixed-in",
"outbound": "vless-out"
}
]
}
}
|
- 运行客户端并测试
- Windows/macOS/Linux: 在终端中,进入 sing-box 目录,运行
./sing-box run -c config.json。
- 配置系统代理: 将你设备的系统代理或浏览器的代理设置为:
- HTTP/HTTPS 代理:
127.0.0.1, 端口 1080
- SOCKS5 代理:
127.0.0.1, 端口 1080
- 打开浏览器,访问
https://www.google.com 或 https://ipinfo.io。如果能正常访问,并且 ipinfo.io 显示的 IP 是 Cloudflare 的 IP,那么恭喜你,全部配置成功!
总结与排错
- 连接失败:
- 检查服务端
sing-box 状态是否为 active (running)。
- 检查 VPS 防火墙是否放行 80 和 443 端口。
- 检查 Cloudflare DNS 解析是否正确,橙色云朵是否点亮。
- 检查客户端和服务端的
uuid, path, Host 是否完全一致。
- TLS/SSL 错误:
- 确认 Cloudflare SSL/TLS 模式是
完全 (严格)。
- 确认服务器上的证书路径和权限正确。
- 速度慢:
- 可以尝试更换 Cloudflare 的 IP 段(有相关工具和脚本)。
- 检查客户端和服务器之间的网络延迟。
这份指南涵盖了从零开始搭建 VLESS+WS+CDN+TLS 的所有核心步骤。祝你使用愉快!
以上内容由AI生成,仅供参考和借鉴
[/details]
[details=“Qwen Chat 网页版 Qwen3-Max”]
基于搜索结果,我为您详细介绍如何使用sing-box内核搭建VLESS+WS+CDN+TLS的完整配置方案。
一、整体架构说明
VLESS+WS+TLS+CDN的架构中,Cloudflare作为CDN层,可以有效隐藏真实服务器IP,避免被墙。 使用websocket传输方式的配置可以套cdn使用,这是实现流量伪装的关键。
二、服务端配置文件
1. 创建配置文件
首先在服务器上创建sing-box配置文件:
1
2
|
mkdir -p /etc/sing-box
vim /etc/sing-box/config.json
|
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
{
"log": {
"level": "info",
"output": "/var/log/sing-box.log"
},
"inbounds": [
{
"type": "vless",
"listen": "::",
"listen_port": 443,
"users": [
{
"uuid": "您的UUID",
"flow": ""
}
],
"tls": {
"enabled": true,
"server_name": "your.domain.com",
"certificate_path": "/etc/letsencrypt/live/your.domain.com/fullchain.pem",
"key_path": "/etc/letsencrypt/live/your.domain.com/privkey.pem"
},
"transport": {
"type": "websocket",
"path": "/websocket-path",
"headers": {
"Host": "your.domain.com"
}
}
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
],
"route": {
"rules": [
{
"ip_is_private": true,
"outbound": "direct"
},
{
"rule_set": "geosite-category-ads-all",
"outbound": "block"
}
],
"rule_set": [
{
"tag": "geosite-category-ads-all",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs",
"download_detour": "direct"
}
]
}
}
|
三、客户端配置文件
客户端完整配置示例
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
{
"log": {
"level": "info",
"output": "console"
},
"inbounds": [
{
"type": "mixed",
"listen": "127.0.0.1",
"listen_port": 7890,
"sniff": true
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "your.domain.com",
"server_port": 443,
"uuid": "您的UUID",
"flow": "",
"tls": {
"enabled": true,
"server_name": "your.domain.com",
"insecure": false
},
"transport": {
"type": "websocket",
"path": "/websocket-path",
"headers": {
"Host": "your.domain.com"
}
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
],
"route": {
"rules": [
{
"domain_suffix": ["cn"],
"outbound": "direct"
},
{
"geosite": "cn",
"outbound": "direct"
},
{
"ip_cidr": ["240.0.0.0/4", "ff00::/8"],
"outbound": "block"
},
{
"rule_set": "geosite-category-ads-all",
"outbound": "block"
}
],
"rule_set": [
{
"tag": "geosite-category-ads-all",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs",
"download_detour": "direct"
}
],
"final": "proxy"
}
}
|
四、CDN(Cloudflare)配置步骤
- 域名解析:将您的域名DNS解析到Cloudflare,确保状态为"Proxied"(橙色云图标)
- SSL/TLS设置:
- SSL/TLS模式:选择"Full"或"Full (strict)"
- 最小TLS版本:建议TLS 1.2
- 通用SSL:开启
- 网络设置:
- HTTP/2:开启
- HTTP/3 (QUIC):开启
- Brotli:开启
- 防火墙规则:建议创建规则只允许Cloudflare IP访问服务器443端口
五、Nginx反向代理配置(可选)
如果需要多协议共存,可以使用Nginx做SNI分流:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name your.domain.com;
ssl_certificate /etc/letsencrypt/live/your.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.domain.com/privkey.pem;
location /websocket-path {
proxy_pass http://127.0.0.1:8080; # sing-box监听的内部端口
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 重要:超时设置
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
send_timeout 86400s;
}
}
|
六、部署步骤
- 安装sing-box:
1
2
3
|
curl -L https://github.com/SagerNet/sing-box/releases/latest/download/sing-box-$(uname -m)-linux.tar.gz | tar xz
sudo mv sing-box /usr/local/bin/
sudo chmod +x /usr/local/bin/sing-box
|
- 获取SSL证书(使用acme.sh):
1
2
3
|
curl https://get.acme.sh | sh
source ~/.bashrc
acme.sh --issue -d your.domain.com --standalone
|
- 创建systemd服务:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
sudo tee /etc/systemd/system/sing-box.service > /dev/null <<EOF
[Unit]
Description=sing-box service
Documentation=https://sing-box.sagernet.org/
After=network.target nss-lookup.target
[Service]
User=root
WorkingDirectory=/etc/sing-box
ExecStart=/usr/local/bin/sing-box run -c /etc/sing-box/config.json
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
EOF
|
- 启动服务:
1
2
3
|
sudo systemctl daemon-reload
sudo systemctl enable sing-box
sudo systemctl start sing-box
|
七、重要注意事项
- UUID生成:使用
uuidgen命令生成,或在线UUID生成器
- 路径伪装:WebSocket路径建议使用随机字符串,增加隐蔽性
- 防火墙设置:确保443端口开放,其他端口根据需要开放
- 证书更新:设置自动更新Let’s Encrypt证书的cron任务
- 日志管理:定期清理日志文件,避免磁盘空间不足
八、验证方法
- 服务端检查:
1
2
|
sudo systemctl status sing-box
journalctl -u sing-box -f
|
- 客户端测试:
1
2
|
sing-box check -c client.json
sing-box run -c client.json
|
- 连接测试:
1
|
curl -x http://127.0.0.1:7890 https://ipinfo.io
|
通过以上配置,您可以成功搭建一个VLESS+WS+TLS+CDN的sing-box服务,有效提升连接的稳定性和隐蔽性。 这种配置方式能够很好地适应各种网络环境,特别是在需要流量伪装的场景下表现优异。
[/details]
[details=“魔搭社区 Qwen/Qwen3-VL-235B-A22B-Instruct”]
使用 sing-box 内核搭建 VLESS + WebSocket + CDN + TLS 的完整配置方法如下。这种组合常用于穿透防火墙、隐藏真实 IP,提升隐蔽性和可用性。
📌 一、前置条件
- 域名:已解析到你的服务器(如
vless.example.com)
- SSL证书:可使用 Let’s Encrypt 自动签发,或手动上传证书文件
- CDN服务:如 Cloudflare、Akamai、阿里云CDN等(建议开启“代理”模式)
- 服务器开放端口:通常为 443(TLS)或 80(用于 ACME 验证)
- sing-box 已安装:推荐最新版本(>= v1.8.0)
🛠️ 二、服务端配置(sing-box server)
假设你使用的是 vless://uuid@domain:443?encryption=none&security=tls&type=ws&host=domain&path=/vless 格式
✅ 服务端 sing-box 配置文件(server.json)
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
|
{
"log": {
"level": "info",
"output": "stdout"
},
"inbounds": [
{
"type": "vless",
"tag": "vless-ws-in",
"listen": "::",
"listen_port": 443,
"users": [
{
"uuid": "your-uuid-here", // 替换为你自己的 UUID
"flow": "" // 可选,如 xtls-rprx-direct
}
],
"transport": {
"type": "websocket",
"path": "/vless", // WebSocket 路径
"early_data_header_name": "Sec-WebSocket-Protocol"
},
"tls": {
"enabled": true,
"server_name": "vless.example.com", // 你的域名
"certificate_path": "/path/to/fullchain.pem", // 证书路径
"key_path": "/path/to/privkey.pem" // 私钥路径
}
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct"
}
]
}
|
💡 如果你用的是 Let’s Encrypt,证书路径通常是:
/etc/letsencrypt/live/vless.example.com/fullchain.pem
/etc/letsencrypt/live/vless.example.com/privkey.pem
🌐 三、客户端配置(sing-box client)
客户端需连接到 CDN 解析后的 IP(实际是 CDN 节点),由 CDN 代转到你的服务器
✅ 客户端 sing-box 配置文件(client.json)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
{
"log": {
"level": "info",
"output": "stdout"
},
"dns": {
"servers": [
{
"tag": "local",
"address": "https://1.1.1.1/dns-query"
}
],
"rules": [
{
"rule_set": ["geosite-cn"],
"server": "local"
}
]
},
"inbounds": [
{
"type": "mixed",
"listen": "127.0.0.1",
"listen_port": 7890
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "vless.example.com", // 你的域名(CDN 代理的)
"server_port": 443,
"uuid": "your-uuid-here", // 必须与服务端一致
"flow": "", // 可选
"transport": {
"type": "websocket",
"path": "/vless", // 必须与服务端一致
"headers": {
"Host": "vless.example.com" // 必须与服务端 tls.server_name 一致
}
},
"tls": {
"enabled": true,
"server_name": "vless.example.com", // 必须与域名一致
"insecure": false // 生产环境务必设为 false
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
],
"route": {
"rules": [
{
"inbound": "mixed-in",
"outbound": "proxy"
}
]
}
}
|
🔐 四、证书获取(Let’s Encrypt 示例)
1
2
3
4
5
6
7
8
9
|
# 安装 certbot
sudo apt update && sudo apt install certbot
# 获取证书(假设你有 Nginx 或 Caddy,或临时用 --standalone)
sudo certbot certonly --standalone -d vless.example.com
# 证书默认位置
/etc/letsencrypt/live/vless.example.com/fullchain.pem
/etc/letsencrypt/live/vless.example.com/privkey.pem
|
⚠️ 注意:如果使用 CDN,不能在服务器上直接运行 --webroot,因为 CDN 会拦截验证请求。建议:
- 临时关闭 CDN 代理(仅限 DNS 解析),完成验证后再打开。
- 或使用 DNS API 自动验证(如 Cloudflare API)。
🌍 五、CDN 设置(以 Cloudflare 为例)
- 登录 Cloudflare → 选择你的域名 → DNS → 添加 A 记录指向服务器 IP
- 点击记录右侧 “Proxy status” → 改为 Proxied(橙色云)
- 在 SSL/TLS → Overview → 选择 Full(严格)
✅ 这样流量经过 Cloudflare 加密转发,隐藏了真实服务器 IP,同时支持 TLS 终止在 CDN 层(但 sing-box 仍需要后端 TLS,所以选 Full 严格模式)
🧪 六、启动服务
启动服务端:
1
|
sudo sing-box run -c /path/to/server.json
|
启动客户端:
1
|
sing-box run -c /path/to/client.json
|
客户端监听 127.0.0.1:7890,可配置浏览器代理或系统全局代理。
🧩 七、高级优化(可选)
1. 使用 fallback 处理 HTTP 请求(防止被探测)
1
2
3
4
5
|
// 服务端 inbound 中添加
"fallback": {
"server": "127.0.0.1",
"server_port": 8080
}
|
然后在 8080 端口跑一个静态网页或 Nginx,伪装成正常网站。
2. 使用 alpn 提升兼容性
1
2
3
4
5
6
7
|
"tls": {
"enabled": true,
"server_name": "vless.example.com",
"certificate_path": "...",
"key_path": "...",
"alpn": ["h2", "http/1.1"]
}
|
✅ 八、验证是否成功
- 客户端配置好后,访问 https://www.ip138.com/ 查看出口 IP 是否为 CDN IP
- 使用
curl -v https://vless.example.com/vless 应该返回 400(WebSocket 协议错误是正常的)
- 使用 V2Ray/V2RayN/Trojan-Go 等客户端导入配置测试连通性
📝 九、常见问题
| 问题 |
解决方案 |
ERR_CONNECTION_REFUSED |
检查端口是否开放、防火墙是否放行 443、CDN 是否代理正确 |
TLS handshake failed |
检查证书路径、域名匹配、insecure=false |
WebSocket not supported |
检查 path 和 headers.Host 是否一致 |
UUID 不匹配 |
客户端和服务端必须使用相同 UUID |
📚 十、参考文档
- sing-box 官方文档:https://sing-box.sagernet.org/
- VLESS 协议说明:https://xtls.github.io/protocols/vless.html
- Cloudflare + VLESS 教程:https://github.com/XTLS/Xray-examples
✅ 至此,你已成功使用 sing-box 搭建了 VLESS + WebSocket + CDN + TLS 的高性能、高隐蔽性代理服务!
如需进一步支持(如自动续期证书、多用户管理、日志分析等),欢迎继续提问!
[/details]
[details=“魔搭社区 deepseek-ai/DeepSeek-V3.2”]
我来详细介绍如何使用 sing-box 内核配置 VLESS + WS + CDN + TLS。
1. 配置文件结构
服务端配置 (server.json)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
{
"log": {
"level": "info",
"timestamp": true
},
"inbounds": [
{
"type": "vless",
"tag": "vless-in",
"listen": "::",
"listen_port": 443,
"tcp_fast_open": true,
"sniff": true,
"sniff_override_destination": true,
"users": [
{
"name": "your-username",
"uuid": "your-uuid", // 生成: uuidgen 或在线生成
"flow": ""
}
],
"transport": {
"type": "ws",
"path": "/your-path", // 自定义路径,如 /vlessws
"headers": {
"Host": "your-domain.com" // 你的域名
}
},
"tls": {
"enabled": true,
"server_name": "your-domain.com",
"certificate_path": "/path/to/fullchain.pem", // SSL证书路径
"key_path": "/path/to/privkey.pem"
}
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
],
"route": {
"rules": [
{
"inbound": ["vless-in"],
"outbound": "direct"
}
]
}
}
|
客户端配置 (client.json)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
{
"log": {
"level": "info",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "remote",
"address": "tls://1.1.1.1",
"detour": "proxy"
},
{
"tag": "local",
"address": "223.5.5.5",
"detour": "direct"
}
],
"strategy": "ipv4_only"
},
"inbounds": [
{
"type": "mixed",
"tag": "socks-in",
"listen": "127.0.0.1",
"listen_port": 1080,
"sniff": true
},
{
"type": "tun",
"tag": "tun-in",
"interface_name": "tun0",
"mtu": 9000,
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"auto_route": true,
"strict_route": true,
"sniff": true
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "your-domain.com", // 你的域名
"server_port": 443,
"uuid": "your-uuid", // 与服务端相同
"flow": "",
"tls": {
"enabled": true,
"server_name": "your-domain.com",
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
},
"transport": {
"type": "ws",
"path": "/your-path", // 与服务端相同
"headers": {
"Host": "your-domain.com"
},
"max_early_data": 2048,
"early_data_header_name": "Sec-WebSocket-Protocol"
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
],
"route": {
"rules": [
{
"protocol": "dns",
"outbound": "proxy"
},
{
"domain_keyword": [
"cloudflare",
"cdn"
],
"outbound": "direct"
},
{
"geoip": [
"cn",
"private"
],
"outbound": "direct"
}
],
"auto_detect_interface": true
}
}
|
2. 部署步骤
步骤1:准备服务器和域名
- 购买 VPS 服务器
- 注册域名并解析到服务器 IP
- 在 Cloudflare 或其他 CDN 中添加域名
步骤2:申请 SSL 证书
1
2
3
4
5
6
7
8
9
10
|
# 使用 acme.sh 申请证书
curl https://get.acme.sh | sh
~/.acme.sh/acme.sh --register-account
~/.acme.sh/acme.sh --issue -d your-domain.com --standalone
# 复制证书到合适位置
mkdir -p /etc/sing-box/cert
~/.acme.sh/acme.sh --install-cert -d your-domain.com \
--key-file /etc/sing-box/cert/privkey.pem \
--fullchain-file /etc/sing-box/cert/fullchain.pem
|
步骤3:安装 sing-box
1
2
3
4
5
6
7
|
# 下载最新版 sing-box
curl -Lo /tmp/sing-box.tar.gz https://github.com/SagerNet/sing-box/releases/latest/download/sing-box-1.8.0-linux-amd64.tar.gz
tar -xzf /tmp/sing-box.tar.gz -C /tmp
install -m 755 /tmp/sing-box-*/sing-box /usr/local/bin/
# 验证安装
sing-box version
|
步骤4:配置 systemd 服务
创建 /etc/systemd/system/sing-box.service:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[Unit]
Description=sing-box Service
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/sing-box run -c /etc/sing-box/config.json
Restart=on-failure
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
|
启动服务:
1
2
3
4
|
systemctl daemon-reload
systemctl enable sing-box
systemctl start sing-box
systemctl status sing-box
|
步骤5:CDN 配置(以 Cloudflare 为例)
-
在 Cloudflare DNS 设置中:
- 添加 A 记录指向你的服务器 IP
- 启用代理状态(橙色云图标)
-
SSL/TLS 设置:
-
网络设置:
步骤6:客户端使用
- 将客户端配置文件保存为
config.json
- 启动 sing-box 客户端:
1
|
sing-box run -c config.json
|
- 配置系统代理或使用支持 sing-box 的客户端
3. 注意事项
防火墙配置
1
2
3
4
5
6
7
|
# 开放端口
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
# 或者使用 iptables
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
|
性能优化
- 启用 TCP Fast Open(已在配置中)
- 调整内核参数:
1
2
|
echo "net.ipv4.tcp_fastopen=3" >> /etc/sysctl.conf
sysctl -p
|
- BBR 拥塞控制:
1
2
3
|
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
|
安全建议
- 定期更新 UUID
- 使用复杂的路径
- 监控日志
- 定期更新 sing-box 版本
4. 故障排查
常见问题
-
连接失败
- 检查防火墙设置
- 验证证书路径
- 确认 CDN 已启用 WebSocket
-
速度慢
-
证书错误
- 确保证书有效
- 检查证书权限
- 重启 sing-box 服务
查看日志
1
2
3
4
5
|
# 服务端日志
journalctl -u sing-box -f
# 客户端日志
sing-box run -c config.json --debug
|
这个配置支持通过 CDN 中转流量,提供了更好的隐蔽性和抗干扰能力。记得替换配置文件中的占位符为你自己的信息。
[/details]
总结:
但从入站,出站来看:
| 渠道 |
正确/错误 |
备注 |
| Gemini AI Pro 思考模式(3 Pro) |
正确 |
|
| Chatgpt 网页免费版 |
错误 |
大错特错 |
| Deepseek 网页版,开启深度思考和联网搜索 |
错误 |
回答没有完全遵循指令 |
| 智谱清言 网页版 GLM4.6 开启推理 |
正确 |
提示友好 |
| Qwen Chat 网页版 Qwen3-Max |
错误 |
小错误,懂的话还可以修改,不懂就难了 |
| 魔搭社区 Qwen/Qwen3-VL-235B-A22B-Instruct |
错误 |
小错误,懂的话还可以修改,不懂就难了 |
| 魔搭社区 deepseek-ai/DeepSeek-V3.2 |
错误 |
|
| 渠道 |
正确/错误 |
备注 |
| Gemini AI Pro 思考模式(3 Pro) |
正确 |
|
| Chatgpt 网页免费版 |
错误 |
大错特错 |
| Deepseek 网页版,开启深度思考和联网搜索 |
错误 |
回答没有完全遵循指令 |
| 智谱清言 网页版 GLM4.6 开启推理 |
正确 |
提示友好 |
| Qwen Chat 网页版 Qwen3-Max |
错误 |
小错误,懂的话还可以修改,不懂就难了 |
| 魔搭社区 Qwen/Qwen3-VL-235B-A22B-Instruct |
错误 |
小错误,懂的话还可以修改,不懂就难了 |
| 魔搭社区 deepseek-ai/DeepSeek-V3.2 |
错误 |
|