负载均衡终于整上了,接下来该弄qb代理了

This commit is contained in:
2026-06-30 13:52:46 +08:00
parent d5d02f65c4
commit 58f6a2a67f
4 changed files with 145 additions and 117 deletions
+29 -24
View File
@@ -19,19 +19,20 @@
--- ---
## Nginx SNI 分流 (`beijing-vps-stream.conf`) ## Nginx SNI 分流 (`北京vps-stream.conf`)
监听 `:443`,按 SNI 将流量分发到不同后端 **端口 443 — 公网入口**,按 SNI 分发流量
| SNI | 后端 | 端口 | 用途 | | SNI | 后端 | 端口 | 用途 |
|---|---|---|---| |---|---|---|---|
| `www.apple.com` | Xray interconn | :9443 | 反向代理隧道 | | `www.apple.com` / `www.samsung.com` / `addons.mozilla.org` | Xray interconn | :9443 | 反向代理隧道(多 SNI 轮换) |
| `www.microsoft.com` | Xray mihomo_in | :9444 | Mihomo 客户端 → 搬瓦工出口 | | `news.apple.com` | Xray proxy_from_lan | :9445 | 北京直连代理(qBittorrent 出站) |
| `news.apple.com` | Xray proxy_from_lan | :9445 | 北京直连代理 |
| `drive.salmonstill.cn` | NAS | :38653 | 绿联云直接转发 | | `drive.salmonstill.cn` | NAS | :38653 | 绿联云直接转发 |
| 默认 | NPM | :8443 | Nginx Proxy Manager | | 默认 | NPM | :8443 | Nginx Proxy Manager |
搬瓦工 VPS(部署 `东京-vps-stream.conf` + `tokyo-vps-config.json`):`www.microsoft.com` → Xray :9443,默认 → NPM **端口 9447 — 数据中心回落**:Reality 探针/探测流量回落到此,按 SNI 代理到真实网站
搬瓦工 VPS(部署 `代理vps-stream.conf` + `xray-代理服务器-config.json`):`www.cloudflare.com` → Xray :9443,默认 → NPM。
--- ---
@@ -41,11 +42,12 @@
**Reality 入站** — 共享 privateKey `GGT9LfN_...`,由 Nginx SNI 转发: **Reality 入站** — 共享 privateKey `GGT9LfN_...`,由 Nginx SNI 转发:
| Tag | 端口 | SNI | Reality target | | Tag | 端口 | serverNames | Reality target | 说明 |
|---|---|---|---| |---|---|---|---|---|
| `interconn` | :9443 | `www.apple.com` | `www.apple.com:443` | | `interconn` | :9443 | apple/samsung/mozilla 轮换 | `127.0.0.1:9447` | 反向隧道,多 SNI 防封 + 数据中心回落 |
| `mihomo_in` | :9444 | `www.microsoft.com` | `www.microsoft.com:443` | | `proxy_from_lan` | :9445 | `news.apple.com` | `www.apple.com:443` | 北京直连代理(qBittorrent |
| `proxy_from_lan` | :9445 | `news.apple.com` | `www.apple.com:443` |
> `mihomo_in`(旧 Mihomo 中转)已删除,客户端直接连接搬瓦工。
**dokodemo-door 入站** — 端口转发到旁路由反向隧道,共 11 个: **dokodemo-door 入站** — 端口转发到旁路由反向隧道,共 11 个:
@@ -71,12 +73,13 @@
| Tag | 端口 | 类型 | 用途 | | Tag | 端口 | 类型 | 用途 |
|---|---|---|---| |---|---|---|---|
| `proxy_in` | 10809 | mixed | SOCKS5/HTTP 代理 → 搬瓦工出口 |
| `socks-dynamic` | 38658 | SOCKS5 (password) | 动态 LAN 端口访问 | | `socks-dynamic` | 38658 | SOCKS5 (password) | 动态 LAN 端口访问 |
**出站**`direct`freedom 直连)`to_tokyo`VLESS+Reality → `67.230.189.235:443` **出站**`direct`freedom 直连)
**路由**:所有 `external_*` + `interconn` + `socks-dynamic``portal`(反向隧道);`mihomo_in` + `proxy_in``to_tokyo``proxy_from_lan``direct` **路由**:所有 `external_*` + `interconn` + `socks-dynamic``portal`(反向隧道);`interconn` 探测流量(baidu.com)→ `direct``proxy_from_lan``direct`
> `mihomo_in` + `proxy_in` + `to_tokyo` 旧中转链路(北京→搬瓦工),已删除。
### 旁路由 (`xray-旁路由-config.json`) ### 旁路由 (`xray-旁路由-config.json`)
@@ -100,7 +103,7 @@
| `to_spark_ssh` | `192.168.1.166:22` | Spark SSH 远程 | | `to_spark_ssh` | `192.168.1.166:22` | Spark SSH 远程 |
| `to_spark_rdp` | `192.168.1.166:3389` | Spark xRDP 桌面远程 | | `to_spark_rdp` | `192.168.1.166:3389` | Spark xRDP 桌面远程 |
| `to_spark_38662` | `192.168.1.166:38662` | Spark 自定义服务 | | `to_spark_38662` | `192.168.1.166:38662` | Spark 自定义服务 |
| `interconn` | VLESS+Reality → `salmonstill.cn:443` (SNI=www.apple.com) | 隧道链接 | | `interconn-apple/samsung/mozilla` | VLESS+Reality → `salmonstill.cn:443` (SNI 轮换) | 隧道链接(balancer + leastPing + fallback |
| `to_beijing_direct` | VLESS+Reality → `salmonstill.cn:443` (SNI=news.apple.com) | 北京直连 | | `to_beijing_direct` | VLESS+Reality → `salmonstill.cn:443` (SNI=news.apple.com) | 北京直连 |
| `direct` | freedom | 直连 | | `direct` | freedom | 直连 |
@@ -127,9 +130,9 @@
> 所有显式端口规则优先于 catch-all,现有端口转发不受影响。 > 所有显式端口规则优先于 catch-all,现有端口转发不受影响。
### 搬瓦工 VPS / 洛杉矶 (`tokyo-vps-config.json`) ### 搬瓦工 VPS (`xray-代理服务器-config.json`)
极简:VLESS+Reality 入站 `:9443`SNI=www.microsoft.com),freedom 出站。 极简:VLESS+Reality 入站 `:9443`SNI=www.cloudflare.com, dest=www.cloudflare.com),freedom 出站。
所有客户端(Spark、旁路由、macOS)直连此服务器,不再经北京 VPS 中转。 所有客户端(Spark、旁路由、macOS)直连此服务器,不再经北京 VPS 中转。
--- ---
@@ -149,7 +152,9 @@
配合 **fake-ip DNS**`enhanced-mode: fake-ip`),DNS 请求返回 `198.18.x.x` 假 IP,强制流量进入代理路由。 配合 **fake-ip DNS**`enhanced-mode: fake-ip`),DNS 请求返回 `198.18.x.x` 假 IP,强制流量进入代理路由。
**代理节点** **代理节点**
- `US-Direct` — VLESS+Reality → `67.230.189.235:443`(默认国外出口,客户端直连搬瓦工) - `US-Direct` — VLESS+Reality → `67.230.189.235:443`(默认国外出口,客户端直连搬瓦工SNI=www.cloudflare.com
> `Xray-Real` 代理节点(经北京 VPS 中转)已移除,Mihomo 全部直连搬瓦工。
**关键策略组** **关键策略组**
- 国外 → `[US-Direct, 直连]` - 国外 → `[US-Direct, 直连]`
@@ -862,15 +867,15 @@ BT Peer → salmonstill.cn:51413 → portal → 隧道 → bridge → to_qbit
| 文件 | 目标设备 | 部署路径 | | 文件 | 目标设备 | 部署路径 |
|---|---|---| |---|---|---|---|
| `beijing-vps-stream.conf` | 北京 VPS | `/etc/nginx/stream.conf.d/` | | `北京vps-stream.conf` | 北京 VPS | `/etc/nginx/nginx.conf``stream {}` |
| `xray-北京vps-config.json` | 北京 VPS | `/usr/local/etc/xray/config.json` | | `xray-北京vps-config.json` | 北京 VPS | `/usr/local/etc/xray/config.json` |
| `东京-vps-stream.conf` | 搬瓦工 VPS | `/etc/nginx/stream.conf.d/` | | `代理vps-stream.conf` | 搬瓦工 VPS | `/etc/nginx/nginx.conf``stream {}` |
| `tokyo-vps-config.json` | 搬瓦工 VPS | `/usr/local/etc/xray/config.json` | | `xray-代理服务器-config.json` | 搬瓦工 VPS | `/usr/local/etc/xray/config.json` |
| `xray-旁路由-config.json` | 旁路由 | `/etc/xray/config.json` | | `xray-旁路由-config.json` | 旁路由 | `/etc/xray/config.json` |
| `旁路由的mihomo config.yaml` | 旁路由 | `/opt/mihomo/config.yaml` | | `旁路由的mihomo config.yaml` | 旁路由 | `/opt/mihomo/config.yaml` |
| `非tun模式的主机mihomo config.yaml` | macOS | `~/Library/LaunchAgents/` (launchctl 管理) | | `非tun模式的主机mihomo config.yaml` | macOS | `~/Library/Application Support/mihomo/config.yaml` (launchctl 管理) |
| `tun模式的主机mihomo config.yaml` | Spark (Ubuntu) | `/opt/mihomo/config.yaml` (systemd) | | `tun模式的主机mihomo config.yaml` | Spark (Ubuntu) | `/opt/mihomo/config.yaml`
| `subscribe-7891-only.yaml` | 通用 | 精简版模板(单独 7891 端口) | | `subscribe-7891-only.yaml` | 通用 | 精简版模板(单独 7891 端口) |
| `qbittorrent流量转发.md` | — | 方案文档(已合并到 README,可删除) | | `qbittorrent流量转发.md` | — | 方案文档(已合并到 README,可删除) |
| `我的世界udp转发.md` | — | 方案文档(已合并到 README,可删除) | | `我的世界udp转发.md` | — | 方案文档(已合并到 README,可删除) |
+11 -80
View File
@@ -77,15 +77,7 @@
"network": "tcp" "network": "tcp"
} }
}, },
{
"tag": "proxy_in",
"listen": "127.0.0.1",
"port": 10809,
"protocol": "mixed",
"settings": {
"udp": true
}
},
{ {
"tag": "external_router_web", "tag": "external_router_web",
"listen": "0.0.0.0", "listen": "0.0.0.0",
@@ -160,8 +152,11 @@
"security": "reality", "security": "reality",
"realitySettings": { "realitySettings": {
"show": false, "show": false,
"target": "www.apple.com:443", "target": "127.0.0.1:9447",
"xver": 0,
"serverNames": [ "serverNames": [
"www.samsung.com",
"addons.mozilla.org",
"www.apple.com" "www.apple.com"
], ],
"privateKey": "GGT9LfN_2JdQG68cwrULgUK-adfT6wIokLzWjaB0fXs", "privateKey": "GGT9LfN_2JdQG68cwrULgUK-adfT6wIokLzWjaB0fXs",
@@ -171,36 +166,7 @@
} }
} }
}, },
{
"tag": "mihomo_in",
"listen": "127.0.0.1",
"port": 9444,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "113e167a-a2be-4b46-9010-60020108626c",
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "raw",
"security": "reality",
"realitySettings": {
"show": false,
"target": "www.microsoft.com:443",
"serverNames": [
"www.microsoft.com"
],
"privateKey": "GGT9LfN_2JdQG68cwrULgUK-adfT6wIokLzWjaB0fXs",
"shortIds": [
"7c947a71b94f369e"
]
}
}
},
{ {
"tag": "proxy_from_lan", "tag": "proxy_from_lan",
"listen": "127.0.0.1", "listen": "127.0.0.1",
@@ -307,37 +273,6 @@
{ {
"tag": "direct", "tag": "direct",
"protocol": "freedom" "protocol": "freedom"
},
{
"tag": "to_tokyo",
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "67.230.189.235",
"port": 443,
"users": [
{
"id": "4d222c16-53bb-4402-814e-c8188cebcea6",
"encryption": "none",
"flow": "xtls-rprx-vision"
}
]
}
]
},
"streamSettings": {
"network": "raw",
"security": "reality",
"realitySettings": {
"show": false,
"fingerprint": "chrome",
"serverName": "www.microsoft.com",
"password": "jr_zQjC4mvlQITuG5Ap5Mxqe5EBbGyyvwbVLDEi8OCA",
"shortId": "a1b2c3d4",
"spiderX": "/"
}
}
} }
], ],
"routing": { "routing": {
@@ -458,9 +393,12 @@
{ {
"type": "field", "type": "field",
"inboundTag": [ "inboundTag": [
"proxy_in" "interconn"
], ],
"outboundTag": "to_tokyo" "domain": [
"full:www.baidu.com"
],
"outboundTag": "direct"
}, },
{ {
"type": "field", "type": "field",
@@ -469,13 +407,6 @@
], ],
"outboundTag": "portal" "outboundTag": "portal"
}, },
{
"type": "field",
"inboundTag": [
"mihomo_in"
],
"outboundTag": "to_tokyo"
},
{ {
"type": "field", "type": "field",
"inboundTag": [ "inboundTag": [
+77 -2
View File
@@ -2,6 +2,11 @@
"log": { "log": {
"loglevel": "info" "loglevel": "info"
}, },
"observatory": {
"subjectSelector": ["interconn-apple", "interconn-samsung", "interconn-mozilla"],
"probeUrl": "https://www.baidu.com",
"probeInterval": "1m"
},
"reverse": { "reverse": {
"bridges": [ "bridges": [
{ {
@@ -136,7 +141,7 @@
} }
}, },
{ {
"tag": "interconn", "tag": "interconn-apple",
"protocol": "vless", "protocol": "vless",
"settings": { "settings": {
"vnext": [ "vnext": [
@@ -166,6 +171,68 @@
} }
} }
}, },
{
"tag": "interconn-mozilla",
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "salmonstill.cn",
"port": 443,
"users": [
{
"id": "113e167a-a2be-4b46-9010-60020108626c",
"encryption": "none",
"flow": "xtls-rprx-vision"
}
]
}
]
},
"streamSettings": {
"network": "raw",
"security": "reality",
"realitySettings": {
"show": false,
"fingerprint": "chrome",
"serverName": "addons.mozilla.org",
"password": "62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs",
"shortId": "7c947a71b94f369e",
"spiderX": "/search?q=xray"
}
}
},
{
"tag": "interconn-samsung",
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "salmonstill.cn",
"port": 443,
"users": [
{
"id": "113e167a-a2be-4b46-9010-60020108626c",
"encryption": "none",
"flow": "xtls-rprx-vision"
}
]
}
]
},
"streamSettings": {
"network": "raw",
"security": "reality",
"realitySettings": {
"show": false,
"fingerprint": "chrome",
"serverName": "www.samsung.com",
"password": "62y5gDjPrdeuePGl-D2IW4Cw9Kb8_bSBBTmArvL7Nhs",
"shortId": "7c947a71b94f369e",
"spiderX": "/search?q=xray"
}
}
},
{ {
"tag": "to_beijing_direct", "tag": "to_beijing_direct",
"protocol": "vless", "protocol": "vless",
@@ -203,6 +270,14 @@
} }
], ],
"routing": { "routing": {
"balancers": [
{
"tag": "interconn-balancer",
"selector": ["interconn-apple", "interconn-samsung", "interconn-mozilla"],
"fallbackTag": "interconn-samsung",
"strategy": { "type": "leastPing" }
}
],
"rules": [ "rules": [
{ {
"type": "field", "type": "field",
@@ -219,7 +294,7 @@
"domain": [ "domain": [
"full:reverse-proxy.xray.internal" "full:reverse-proxy.xray.internal"
], ],
"outboundTag": "interconn" "balancerTag": "interconn-balancer"
}, },
{ {
"type": "field", "type": "field",
+28 -11
View File
@@ -1,19 +1,27 @@
stream { stream {
resolver 223.5.5.5;
# === 端口 443Nginx SNI 分流 ===
map $ssl_preread_server_name $backend { map $ssl_preread_server_name $backend {
www.apple.com xray; # 旁路由反向代理隧道 www.samsung.com xray;
www.microsoft.com mihomo; # 新增:mihomo出站流量 addons.mozilla.org xray;
news.apple.com xray_lan; # 新增:旁路由代理直连流量 www.apple.com xray;
drive.salmonstill.cn nas; # 绿联云服务 news.apple.com xray_lan;
default npm; # Nginx Proxy Manager drive.salmonstill.cn nas;
default npm;
} }
# === 端口 9447Reality 回落数据中心 ===
map $ssl_preread_server_name $fallback {
www.samsung.com www.samsung.com:443;
addons.mozilla.org addons.mozilla.org:443;
www.apple.com www.apple.com:443;
default 127.0.0.1:1;
}
upstream xray { upstream xray {
server 127.0.0.1:9443; server 127.0.0.1:9443;
} }
# 新增mihomo upstream
upstream mihomo {
server 127.0.0.1:9444;
}
# 旁路由代理直连
upstream xray_lan { upstream xray_lan {
server 127.0.0.1:9445; server 127.0.0.1:9445;
} }
@@ -23,10 +31,19 @@ stream {
upstream npm { upstream npm {
server 127.0.0.1:8443; server 127.0.0.1:8443;
} }
server { server {
listen 443 reuseport; listen 443 reuseport;
listen [::]:443 reuseport; listen [::]:443 reuseport;
ssl_preread on; ssl_preread on;
proxy_pass $backend; proxy_pass $backend;
} }
}
server {
listen 127.0.0.1:9447;
ssl_preread on;
proxy_pass $fallback;
proxy_download_rate 1m;
proxy_upload_rate 512k;
}
}