sing-box安装配置Vless-vision、Vmess-ws、Hysteria、Tuic、Naiveproxy
- 获取链接
- X
- 电子邮件
- 其他应用
本教程测试环境:ubuntu 24.04 X64
sing-box 是新一代的通用网络代理平台,基本上目前流行的协议都支持,支持基于规则的分流、支持TUN等,支持的平台也很全,有网络代理平台的“瑞士军刀”之称,文档在这里。
sing-box 的优点
协议支持最全面
最新原生支持 Hysteria2、TUIC、VLESS + Reality、ShadowTLS、AnyTLS 等新兴协议对新协议的跟进速度通常快于 Clash 系。
现代化架构
从零设计,代码结构清晰,模块化程度高。
内置强大的 DNS 路由引擎、sniffing(流量探测)、规则集(rule-set) 机制。
跨平台一致性好
官方维护 Windows / macOS / Linux / iOS / Android 客户端(sing-box app / SFI / SFA),配置格式统一。在 iOS 上是目前体验较好的选择之一。
TUN 模式成熟
原生 TUN(gVisor / system stack),透明代理能力强,适合全局接管。
缺点:
配置为 纯 JSON,手写门槛高、可读性一般,容易出错。
生态(图形化面板、订阅转换)不如 Clash 丰富。
版本迭代快,配置格式常有 breaking change,升级需要跟着改配置。
sing-box更新迭代速度很快,新旧版本的配置不一定互相兼容,官方配置参考这里 。
本博文通过sing-box安装目前流行的五种协议Vless-vision、Vmess-ws、Hysteria V2、Tuic V5、Naiveproxy到一个配置文件之中,且只需一个子域名及其证书。
0、申请证书,参考这里第5点,本博文所用域名six.mydomain.com,证书目录/etc/sing
mkdir -p /etc/singacme.sh --issue --dns dns_cf -d six.mydomain.com -k ec-256acme.sh --installcert -d six.mydomain.com --key-file /etc/sing/private.key --fullchain-file /etc/sing/cert.crt --ecc1、安装sing-box服务器端,参考这里
SSH登录服务器,运行以下脚本
curl -fsSL https://sing-box.app/install.sh | shvi /etc/sing-box/config.json{
"log": {
"disabled": false,
"level": "info",
"timestamp": true
},
"inbounds": [
{
"type": "vless",
"tag": "vless-sb",
"listen": "::",
"listen_port": 16589,
"users": [
{
"uuid": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"flow": "xtls-rprx-vision"
}
],
"tls": {
"enabled": true,
"certificate_path": "/etc/sing/cert.crt",
"key_path": "/etc/sing/private.key"
}
},
{
"type": "vmess",
"tag": "vmess-sb",
"listen": "::",
"listen_port": 12095,
"users": [
{
"uuid": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"alterId": 0
}
],
"transport": {
"type": "ws",
"path": "xyzabc"
},
"tls":{
"enabled": true,
"server_name": "six.mydomain.com",
"certificate_path": "/etc/sing/cert.crt",
"key_path": "/etc/sing/private.key"
}
},
{
"type": "hysteria2",
"tag": "hy2-sb",
"listen": "::",
"listen_port": 58378,
"users": [
{
"password": "f8b8c801-3894-45a2-b1f6-d26a04189a70"
}
],
"up_mbps": 100,
"down_mbps": 20,
"tls": {
"enabled": true,
"alpn": [
"h3"
],
"certificate_path": "/etc/sing/cert.crt",
"key_path": "/etc/sing/private.key"
}
},
{
"type":"tuic",
"tag": "tuic5-sb",
"listen": "::",
"listen_port": 16680,
"users": [
{
"uuid": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"password": "f8b8c801-3894-45a2-b1f6-d26a04189a70"
}
],
"congestion_control": "bbr",
"tls":{
"enabled": true,
"alpn": [
"h3"
],
"certificate_path": "/etc/sing/cert.crt",
"key_path": "/etc/sing/private.key"
}
},
{
"type": "naive",
"tag": "naive-sb",
"listen": "::",
"listen_port": 16989,
"users": [
{
"username": "cert",
"password": "f8b8c801-3894-45a2-b1f6-d26a04189a70"
}
],
"tls": {
"enabled": true,
"certificate_path": "/etc/sing/cert.crt",
"key_path": "/etc/sing/private.key"
}
}
],
"outbounds": [
{
"type":"direct",
"tag":"direct"
}
],
"route":{
"rules": [
{
"action": "sniff"
},
{
"network": [
"udp",
"tcp"
],
"action": "route",
"outbound": "direct"
}
],
"final": "direct"
}
}
/usr/bin/sing-box check -c /etc/sing-box/config.jsonsystemctl enable --now sing-boxsudo journalctl -u sing-box --output cat -esudo journalctl -u sing-box --output cat -fufw allow 16589{
"log": {
"disabled": false,
"level": "info",
"timestamp": true
},
"experimental": {
"clash_api": {
"external_controller": "127.0.0.1:9080",
"external_ui": "ui",
"secret": "123456",
"default_mode": "Rule"
},
"cache_file": {
"enabled": true,
"store_dns": true
}
},
"dns": {
"servers": [
{
"tag": "alidns",
"type": "https",
"server": "dns.alidns.com",
"path": "/dns-query",
"domain_resolver": "local"
},
{
"tag": "local",
"type": "udp",
"server": "223.5.5.5"
},
{
"tag": "proxydns",
"type": "https",
"server": "dns.google",
"path": "/dns-query",
"detour": "select"
}
],
"rules": [
{
"rule_set": "geosite-cn",
"server": "alidns"
},
{
"clash_mode": "direct",
"server": "alidns"
},
{
"clash_mode": "global",
"server": "proxydns"
}
],
"final": "proxydns",
"strategy": "prefer_ipv4",
"reverse_mapping": true
},
"inbounds": [
{
"type": "tun",
"tag": "tun-in",
"address": [
"172.19.0.1/30",
"fdfe:dcba:9876::1/126"
],
"auto_route": true,
"strict_route": true,
"stack": "system"
}
],
"outbounds": [
{
"tag": "select",
"type": "selector",
"default": "auto",
"outbounds": [
"auto",
"vless-sb",
"naive-sb",
"vmess-sb",
"hy2-sb",
"tuic5-sb"
]
},
{
"type": "vless",
"tag": "vless-sb",
"server": "six.mydomain.com",
"server_port": 16589,
"uuid": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"flow": "xtls-rprx-vision",
"tls": {
"enabled": true,
"server_name": "six.mydomain.com",
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
}
},
{
"type": "naive",
"tag": "naive-sb",
"server": "six.mydomain.com",
"server_port": 16989,
"username": "sing",
"password": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"insecure_concurrency": 0,
"udp_over_tcp": {
"enabled": true,
"version": 2
},
"tls": {
"enabled": true,
"server_name": "six.mydomain.com",
"insecure": false
}
},
{
"type": "vmess",
"tag": "vmess-sb",
"server": "six.mydomain.com",
"server_port": 12095,
"security": "auto",
"uuid": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"tls": {
"enabled": true,
"server_name": "six.mydomain.com",
"insecure": false,
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
},
"transport": {
"headers": {
"Host": [
"six.mydomain.com"
]
},
"path": "xyzabc",
"type": "ws"
}
},
{
"type": "hysteria2",
"tag": "hy2-sb",
"server": "six.mydomain.com",
"server_port": 58378,
"password": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"tls": {
"enabled": true,
"server_name": "six.mydomain.com",
"insecure": true,
"alpn": [
"h3"
]
}
},
{
"type":"tuic",
"tag": "tuic5-sb",
"server": "six.mydomain.com",
"server_port": 16680,
"uuid": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"password": "f8b8c801-3894-45a2-b1f6-d26a04189a70",
"congestion_control": "bbr",
"udp_relay_mode": "native",
"udp_over_stream": false,
"zero_rtt_handshake": false,
"heartbeat": "10s",
"tls":{
"enabled": true,
"server_name": "six.mydomain.com",
"insecure": true,
"alpn": [
"h3"
]
}
},
{
"tag": "direct",
"type": "direct"
},
{
"tag": "auto",
"type": "urltest",
"outbounds": [
"vless-sb",
"naive-sb",
"vmess-sb",
"hy2-sb",
"tuic5-sb"
],
"url": "https://www.gstatic.com/generate_204",
"interval": "1m",
"tolerance": 50,
"interrupt_exist_connections": false
}
],
"route": {
"rule_set": [
{
"tag": "geosite-cn",
"type": "remote",
"format": "binary",
"url": "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/geolocation-cn.srs",
"http_client": {
"detour": "select"
}
},
{
"tag": "geoip-cn",
"type": "remote",
"format": "binary",
"url": "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/cn.srs",
"http_client": {
"detour": "select"
}
}
],
"auto_detect_interface": true,
"final": "select",
"default_domain_resolver": {
"server": "alidns"
},
"rules": [
{
"action": "sniff"
},
{
"type": "logical",
"mode": "or",
"rules": [
{
"port": 53
},
{
"protocol": "dns"
}
],
"action": "hijack-dns"
},
{
"ip_is_private": true,
"action": "route",
"outbound": "direct"
},
{
"clash_mode": "Direct",
"action": "route",
"outbound": "direct"
},
{
"clash_mode": "Global",
"action": "route",
"outbound": "select"
},
{
"rule_set": [
"geoip-cn",
"geosite-cn"
],
"action": "route",
"outbound": "direct"
}
]
},
"ntp": {
"enabled": true,
"server": "time.apple.com",
"server_port": 123,
"interval": "30m",
"detour": "direct"
}
}
"inbounds": [
{
"type": "mixed",
"listen": "127.0.0.1",
"listen_port": 1089
}
]<service>
<id>sing-box</id>
<name>sing-box</name>
<description>This service runs sing-box continuous integration system.</description>
<executable>D:\sing-box\sing-box.exe</executable>
<arguments>run -c D:\sing-box\config.json</arguments>
<log mode="reset"/>
<onfailure action="restart"/>
</service>.\winsw.exe install
.\winsw.exe start .\winsw.exe stop- 获取链接
- X
- 电子邮件
- 其他应用

评论
发表评论