Fix json format

close https://github.com/XTLS/Xray-docs-next/pull/83
Thanks: @Johnshall
pull/86/head
hmol233 2021-07-16 00:29:22 +08:00
parent 2756718446
commit f6cca08099
No known key found for this signature in database
GPG Key ID: D617A9DAB0C992D5
6 changed files with 581 additions and 596 deletions

View File

@ -201,7 +201,7 @@
4. 将下面的文件全部复制进去,并将之前生成的`UUID`填入第 61 行 `"id": "",` 之中。(填好之后的样子是 `"id": "uuiduuid-uuid-uuid-uuid-uuiduuiduuid"` 4. 将下面的文件全部复制进去,并将之前生成的`UUID`填入第 61 行 `"id": "",` 之中。(填好之后的样子是 `"id": "uuiduuid-uuid-uuid-uuid-uuiduuiduuid"`
),本文的这个配置文件中增加了我的各种啰嗦注解,以方便你理解每一个配置模块的功能是什么。 ),本文的这个配置文件中增加了我的各种啰嗦注解,以方便你理解每一个配置模块的功能是什么。
```json5 ```json
// REFERENCE: // REFERENCE:
// https://github.com/XTLS/Xray-examples // https://github.com/XTLS/Xray-examples
// https://xtls.github.io/config/ // https://xtls.github.io/config/
@ -213,92 +213,92 @@
// └─ 5_outbounds 出站设置 - 流出 Xray 的流量往哪里去 // └─ 5_outbounds 出站设置 - 流出 Xray 的流量往哪里去
{ {
// 1\_日志设置 // 1\_日志设置
log: { "log": {
loglevel: "warning", // 内容从少到多: "none", "error", "warning", "info", "debug" "loglevel": "warning", // 内容从少到多: "none", "error", "warning", "info", "debug"
access: "/home/vpsadmin/xray_log/access.log", // 访问记录 "access": "/home/vpsadmin/xray_log/access.log", // 访问记录
error: "/home/vpsadmin/xray_log/error.log", // 错误记录 "error": "/home/vpsadmin/xray_log/error.log" // 错误记录
}, },
// 2_DNS 设置 // 2_DNS 设置
dns: { "dns": {
servers: [ "servers": [
"https+local://1.1.1.1/dns-query", // 首选 1.1.1.1 的 DoH 查询,牺牲速度但可防止 ISP 偷窥 "https+local://1.1.1.1/dns-query", // 首选 1.1.1.1 的 DoH 查询,牺牲速度但可防止 ISP 偷窥
"localhost", "localhost"
], ]
}, },
// 3*分流设置 // 3*分流设置
routing: { "routing": {
domainStrategy: "AsIs", "domainStrategy": "AsIs",
rules: [ "rules": [
// 3.1 防止服务器本地流转问题:如内网被攻击或滥用、错误的本地回环等 // 3.1 防止服务器本地流转问题:如内网被攻击或滥用、错误的本地回环等
{ {
type: "field", "type": "field",
ip: [ "ip": [
"geoip:private", // 分流条件geoip 文件内,名为"private"的规则(本地) "geoip:private" // 分流条件geoip 文件内,名为"private"的规则(本地)
], ],
outboundTag: "block", // 分流策略:交给出站"block"处理(黑洞屏蔽) "outboundTag": "block" // 分流策略:交给出站"block"处理(黑洞屏蔽)
}, },
// 3.2 屏蔽广告 // 3.2 屏蔽广告
{ {
type: "field", "type": "field",
domain: [ "domain": [
"geosite:category-ads-all", // 分流条件geosite 文件内,名为"category-ads-all"的规则(各种广告域名) "geosite:category-ads-all" // 分流条件geosite 文件内,名为"category-ads-all"的规则(各种广告域名)
],
outboundTag: "block", // 分流策略:交给出站"block"处理(黑洞屏蔽)
},
], ],
"outboundTag": "block" // 分流策略:交给出站"block"处理(黑洞屏蔽)
}
]
}, },
// 4*入站设置 // 4*入站设置
// 4.1 这里只写了一个最简单的 vless+xtls 的入站,因为这是 Xray 最强大的模式。如有其他需要,请根据模版自行添加。 // 4.1 这里只写了一个最简单的 vless+xtls 的入站,因为这是 Xray 最强大的模式。如有其他需要,请根据模版自行添加。
inbounds: [ "inbounds": [
{ {
port: 443, "port": 443,
protocol: "vless", "protocol": "vless",
settings: { "settings": {
clients: [ "clients": [
{ {
id: "", // 填写你的 UUID "id": "", // 填写你的 UUID
flow: "xtls-rprx-direct", "flow": "xtls-rprx-direct",
level: 0, "level": 0,
email: "vpsadmin@yourdomain.com", "email": "vpsadmin@yourdomain.com"
}, }
], ],
decryption: "none", "decryption": "none",
fallbacks: [ "fallbacks": [
{ {
dest: 80, // 默认回落到防探测的代理 "dest": 80 // 默认回落到防探测的代理
}
]
}, },
], "streamSettings": {
}, "network": "tcp",
streamSettings: { "security": "xtls",
network: "tcp", "xtlsSettings": {
security: "xtls", "allowInsecure": false, // 正常使用应确保关闭
xtlsSettings: { "minVersion": "1.2", // TLS 最低版本设置
allowInsecure: false, // 正常使用应确保关闭 "alpn": ["http/1.1"],
minVersion: "1.2", // TLS 最低版本设置 "certificates": [
alpn: ["http/1.1"],
certificates: [
{ {
certificateFile: "/home/vpsadmin/xray_cert/xray.crt", "certificateFile": "/home/vpsadmin/xray_cert/xray.crt",
keyFile: "/home/vpsadmin/xray_cert/xray.key", "keyFile": "/home/vpsadmin/xray_cert/xray.key"
}, }
], ]
}, }
}, }
}, }
], ],
// 5*出站设置 // 5*出站设置
outbounds: [ "outbounds": [
// 5.1 第一个出站是默认规则freedom 就是对外直连vps 已经是外网,所以直连) // 5.1 第一个出站是默认规则freedom 就是对外直连vps 已经是外网,所以直连)
{ {
tag: "direct", "tag": "direct",
protocol: "freedom", "protocol": "freedom"
}, },
// 5.2 屏蔽规则blackhole 协议就是把流量导入到黑洞里(屏蔽) // 5.2 屏蔽规则blackhole 协议就是把流量导入到黑洞里(屏蔽)
{ {
tag: "block", "tag": "block",
protocol: "blackhole", "protocol": "blackhole"
}, }
], ]
} }
``` ```

View File

@ -99,7 +99,7 @@
- 请将 `serverName` 替换成你的真实域名 - 请将 `serverName` 替换成你的真实域名
- 各个配置模块的说明我都已经(很啰嗦的)放在对应的配置点上了 - 各个配置模块的说明我都已经(很啰嗦的)放在对应的配置点上了
```json5 ```json
// REFERENCE: // REFERENCE:
// https://github.com/XTLS/Xray-examples // https://github.com/XTLS/Xray-examples
// https://xtls.github.io/config/ // https://xtls.github.io/config/
@ -114,135 +114,135 @@
{ {
// 1_日志设置 // 1_日志设置
// 注意本例中我默认注释掉了日志文件因为windows, macOS, Linux 需要写不同的路径,请自行配置 // 注意本例中我默认注释掉了日志文件因为windows, macOS, Linux 需要写不同的路径,请自行配置
log: { "log": {
// "access": "/home/local/xray_log/access.log", // 访问记录 // "access": "/home/local/xray_log/access.log", // 访问记录
// "error": "/home/local/xray_log/error.log", // 错误记录 // "error": "/home/local/xray_log/error.log", // 错误记录
loglevel: "warning", // 内容从少到多: "none", "error", "warning", "info", "debug" "loglevel": "warning" // 内容从少到多: "none", "error", "warning", "info", "debug"
}, },
// 2_DNS设置 // 2_DNS设置
dns: { "dns": {
servers: [ "servers": [
// 2.1 国外域名使用国外DNS查询 // 2.1 国外域名使用国外DNS查询
{ {
address: "1.1.1.1", "address": "1.1.1.1",
domains: ["geosite:geolocation-!cn"], "domains": ["geosite:geolocation-!cn"]
}, },
// 2.2 国内域名使用国内DNS查询并期待返回国内的IP若不是国内IP则舍弃用下一个查询 // 2.2 国内域名使用国内DNS查询并期待返回国内的IP若不是国内IP则舍弃用下一个查询
{ {
address: "223.5.5.5", "address": "223.5.5.5",
domains: ["geosite:cn"], "domains": ["geosite:cn"],
expectIPs: ["geoip:cn"], "expectIPs": ["geoip:cn"]
}, },
// 2.3 作为2.2的备份,对国内网站进行二次查询 // 2.3 作为2.2的备份,对国内网站进行二次查询
{ {
address: "114.114.114.114", "address": "114.114.114.114",
domains: ["geosite:cn"], "domains": ["geosite:cn"]
}, },
// 2.4 最后的备份上面全部失败时用本机DNS查询 // 2.4 最后的备份上面全部失败时用本机DNS查询
"localhost", "localhost"
], ]
}, },
// 3_分流设置 // 3_分流设置
// 所谓分流,就是将符合否个条件的流量,用指定`tag`的出站协议去处理对应配置的5.x内容 // 所谓分流,就是将符合否个条件的流量,用指定`tag`的出站协议去处理对应配置的5.x内容
routing: { "routing": {
domainStrategy: "AsIs", "domainStrategy": "AsIs",
rules: [ "rules": [
// 3.1 广告域名屏蔽 // 3.1 广告域名屏蔽
{ {
type: "field", "type": "field",
domain: ["geosite:category-ads-all"], "domain": ["geosite:category-ads-all"],
outboundTag: "block", "outboundTag": "block"
}, },
// 3.2 国内域名直连 // 3.2 国内域名直连
{ {
type: "field", "type": "field",
domain: ["geosite:cn"], "domain": ["geosite:cn"],
outboundTag: "direct", "outboundTag": "direct"
}, },
// 3.3 国内IP直连 // 3.3 国内IP直连
{ {
type: "field", "type": "field",
ip: ["geoip:cn", "geoip:private"], "ip": ["geoip:cn", "geoip:private"],
outboundTag: "direct", "outboundTag": "direct"
}, },
// 3.4 国外域名代理 // 3.4 国外域名代理
{ {
type: "field", "type": "field",
domain: ["geosite:geolocation-!cn"], "domain": ["geosite:geolocation-!cn"],
outboundTag: "proxy", "outboundTag": "proxy"
}, }
// 3.5 默认规则 // 3.5 默认规则
// 在Xray中任何不符合上述路由规则的流量都会默认使用【第一个outbound5.1】的设置所以一定要把转发VPS的outbound放第一个 // 在Xray中任何不符合上述路由规则的流量都会默认使用【第一个outbound5.1】的设置所以一定要把转发VPS的outbound放第一个
], ]
}, },
// 4_入站设置 // 4_入站设置
inbounds: [ "inbounds": [
// 4.1 一般都默认使用socks5协议作本地转发 // 4.1 一般都默认使用socks5协议作本地转发
{ {
tag: "socks-in", "tag": "socks-in",
protocol: "socks", "protocol": "socks",
listen: "127.0.0.1", // 这个是通过socks5协议做本地转发的地址 "listen": "127.0.0.1", // 这个是通过socks5协议做本地转发的地址
port: 10800, // 这个是通过socks5协议做本地转发的端口 "port": 10800, // 这个是通过socks5协议做本地转发的端口
settings: { "settings": {
udp: true, "udp": true
}, }
}, },
// 4.2 有少数APP不兼容socks协议需要用http协议做转发则可以用下面的端口 // 4.2 有少数APP不兼容socks协议需要用http协议做转发则可以用下面的端口
{ {
tag: "http-in", "tag": "http-in",
protocol: "http", "protocol": "http",
listen: "127.0.0.1", // 这个是通过http协议做本地转发的地址 "listen": "127.0.0.1", // 这个是通过http协议做本地转发的地址
port: 10801, // 这个是通过http协议做本地转发的端口 "port": 10801 // 这个是通过http协议做本地转发的端口
}, }
], ],
// 5_出站设置 // 5_出站设置
outbounds: [ "outbounds": [
// 5.1 默认转发VPS // 5.1 默认转发VPS
// 一定放在第一个在routing 3.5 里面已经说明了,这等于是默认规则,所有不符合任何规则的流量都走这个 // 一定放在第一个在routing 3.5 里面已经说明了,这等于是默认规则,所有不符合任何规则的流量都走这个
{ {
tag: "proxy", "tag": "proxy",
protocol: "vless", "protocol": "vless",
settings: { "settings": {
vnext: [ "vnext": [
{ {
address: "a-name.yourdomain.com", // 替换成你的真实域名 "address": "a-name.yourdomain.com", // 替换成你的真实域名
port: 443, "port": 443,
users: [ "users": [
{ {
id: "uuiduuid-uuid-uuid-uuid-uuiduuiduuid", // 和服务器端的一致 "id": "uuiduuid-uuid-uuid-uuid-uuiduuiduuid", // 和服务器端的一致
flow: "xtls-rprx-direct", // Windows, macOS 同学保持这个不变 "flow": "xtls-rprx-direct", // Windows, macOS 同学保持这个不变
// "flow": "xtls-rprx-splice", // Linux和安卓同学请改成Splice性能更强 // "flow": "xtls-rprx-splice", // Linux和安卓同学请改成Splice性能更强
encryption: "none", "encryption": "none",
level: 0, "level": 0
}, }
], ]
}, }
], ]
},
streamSettings: {
network: "tcp",
security: "xtls",
xtlsSettings: {
serverName: "a-name.yourdomain.com", // 替换成你的真实域名
allowInsecure: false, // 禁止不安全证书
},
}, },
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"serverName": "a-name.yourdomain.com", // 替换成你的真实域名
"allowInsecure": false // 禁止不安全证书
}
}
}, },
// 5.2 用`freedom`协议直连出站即当routing中指定'direct'流出时,调用这个协议做处理 // 5.2 用`freedom`协议直连出站即当routing中指定'direct'流出时,调用这个协议做处理
{ {
tag: "direct", "tag": "direct",
protocol: "freedom", "protocol": "freedom"
}, },
// 5.3 用`blackhole`协议屏蔽流量即当routing中指定'block'时,调用这个协议做处理 // 5.3 用`blackhole`协议屏蔽流量即当routing中指定'block'时,调用这个协议做处理
{ {
tag: "block", "tag": "block",
protocol: "blackhole", "protocol": "blackhole"
}, }
], ]
} }
``` ```

View File

@ -6,14 +6,15 @@
如果你用了《小小白白话文》中的[Xray 配置](../level-0/ch07-xray-server.md#_7-4-配置xray),并完成了[HTTP 自动跳转 HTTPS 优化](../level-0/ch07-xray-server.md#_7-8-服务器优化之二-开启http自动跳转https),那么你已经有了基于 `VLESS` 协议的简易回落: 如果你用了《小小白白话文》中的[Xray 配置](../level-0/ch07-xray-server.md#_7-4-配置xray),并完成了[HTTP 自动跳转 HTTPS 优化](../level-0/ch07-xray-server.md#_7-8-服务器优化之二-开启http自动跳转https),那么你已经有了基于 `VLESS` 协议的简易回落:
```json5 ```json
{
"inbounds": [ "inbounds": [
{ {
"port": 443, "port": 443,
"protocol": "vless", "protocol": "vless",
"settings": { "settings": {
"clients": [ "clients": [
... // ... ...
], ],
"decryption": "none", "decryption": "none",
"fallbacks": [ "fallbacks": [
@ -23,10 +24,11 @@
] ]
}, },
"streamSettings": { "streamSettings": {
... // ... ...
} }
} }
] ]
}
``` ```
这一段配置用人话要怎么解释呢? 这一段配置用人话要怎么解释呢?
@ -133,55 +135,55 @@
### 5.1 首先,我将服务器端配置的 443 监听段摘抄如下: ### 5.1 首先,我将服务器端配置的 443 监听段摘抄如下:
```json5 ```json
{ {
port: 443, "port": 443,
protocol: "vless", "protocol": "vless",
settings: { "settings": {
clients: [ "clients": [
{ {
id: "", // 填写你的 UUID "id": "", // 填写你的 UUID
flow: "xtls-rprx-direct", "flow": "xtls-rprx-direct",
level: 0, "level": 0,
email: "love@example.com", "email": "love@example.com"
}, }
], ],
decryption: "none", "decryption": "none",
fallbacks: [ "fallbacks": [
{ {
dest: 1310, // 默认回落到 Xray 的 Trojan 协议 "dest": 1310, // 默认回落到 Xray 的 Trojan 协议
xver: 1, "xver": 1
}, },
{ {
path: "/websocket", // 必须换成自定义的 PATH "path": "/websocket", // 必须换成自定义的 PATH
dest: 1234, "dest": 1234,
xver: 1, "xver": 1
}, },
{ {
path: "/vmesstcp", // 必须换成自定义的 PATH "path": "/vmesstcp", // 必须换成自定义的 PATH
dest: 2345, "dest": 2345,
xver: 1, "xver": 1
}, },
{ {
path: "/vmessws", // 必须换成自定义的 PATH "path": "/vmessws", // 必须换成自定义的 PATH
dest: 3456, "dest": 3456,
xver: 1, "xver": 1
}
]
}, },
], "streamSettings": {
}, "network": "tcp",
streamSettings: { "security": "xtls",
network: "tcp", "xtlsSettings": {
security: "xtls", "alpn": ["http/1.1"],
xtlsSettings: { "certificates": [
alpn: ["http/1.1"],
certificates: [
{ {
certificateFile: "/path/to/fullchain.crt", // 换成你的证书,绝对路径 "certificateFile": "/path/to/fullchain.crt", // 换成你的证书,绝对路径
keyFile: "/path/to/private.key", // 换成你的私钥,绝对路径 "keyFile": "/path/to/private.key" // 换成你的私钥,绝对路径
}, }
], ]
}, }
}, }
} }
``` ```
@ -228,32 +230,32 @@
1. 后续处理回落至 `1310` 端口的流量,按照下面的配置验证、处理: 1. 后续处理回落至 `1310` 端口的流量,按照下面的配置验证、处理:
```json5 ```json
{ {
port: 1310, "port": 1310,
listen: "127.0.0.1", "listen": "127.0.0.1",
protocol: "trojan", "protocol": "trojan",
settings: { "settings": {
clients: [ "clients": [
{ {
password: "", // 填写你的密码 "password": "", // 填写你的密码
level: 0, "level": 0,
email: "love@example.com", "email": "love@example.com"
}, }
], ],
fallbacks: [ "fallbacks": [
{ {
dest: 80, // 或者回落到其它也防探测的代理 "dest": 80 // 或者回落到其它也防探测的代理
}, }
], ]
},
streamSettings: {
network: "tcp",
security: "none",
tcpSettings: {
acceptProxyProtocol: true,
},
}, },
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": true
}
}
} }
``` ```
@ -264,94 +266,94 @@
2. 后续处理回落至 `1234` 端口的流量,仔细看!它其实是 `vless+ws` 2. 后续处理回落至 `1234` 端口的流量,仔细看!它其实是 `vless+ws`
```json5 ```json
{ {
port: 1234, "port": 1234,
listen: "127.0.0.1", "listen": "127.0.0.1",
protocol: "vless", "protocol": "vless",
settings: { "settings": {
clients: [ "clients": [
{ {
id: "", // 填写你的 UUID "id": "", // 填写你的 UUID
level: 0, "level": 0,
email: "love@example.com", "email": "love@example.com"
}, }
], ],
decryption: "none", "decryption": "none"
},
streamSettings: {
network: "ws",
security: "none",
wsSettings: {
acceptProxyProtocol: true, // 提醒:若你用 Nginx/Caddy 等反代 WS需要删掉这行
path: "/websocket", // 必须换成自定义的 PATH需要和分流的一致
},
}, },
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"acceptProxyProtocol": true, // 提醒:若你用 Nginx/Caddy 等反代 WS需要删掉这行
"path": "/websocket" // 必须换成自定义的 PATH需要和分流的一致
}
}
} }
``` ```
3. 后续处理回落至 `2345` 端口的流量,仔细看!它其实是 `vmess直连` 3. 后续处理回落至 `2345` 端口的流量,仔细看!它其实是 `vmess直连`
```json5 ```json
{ {
port: 2345, "port": 2345,
listen: "127.0.0.1", "listen": "127.0.0.1",
protocol: "vmess", "protocol": "vmess",
settings: { "settings": {
clients: [ "clients": [
{ {
id: "", // 填写你的 UUID "id": "", // 填写你的 UUID
level: 0, "level": 0,
email: "love@example.com", "email": "love@example.com"
}, }
], ]
},
streamSettings: {
network: "tcp",
security: "none",
tcpSettings: {
acceptProxyProtocol: true,
header: {
type: "http",
request: {
path: [
"/vmesstcp", // 必须换成自定义的 PATH需要和分流的一致
],
},
},
},
}, },
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": true,
"header": {
"type": "http",
"request": {
"path": [
"/vmesstcp" // 必须换成自定义的 PATH需要和分流的一致
]
}
}
}
}
} }
``` ```
4. 后续处理回落至 `3456` 端口的流量,再仔细看!它其实是是 `vmess+ws(+cdn)` 4. 后续处理回落至 `3456` 端口的流量,再仔细看!它其实是是 `vmess+ws(+cdn)`
::: warning 说明 ::: warning 说明
你没看错,这就是 v2fly 曾经的推荐组合之一,并可完整支持 `CDN`。现已加入完美回落套餐哦! 你没看错,这就是 v2fly 曾经推荐组合之一,并可完整支持 `CDN`。现已加入完美回落套餐哦!
::: :::
```json5 ```json
{ {
port: 3456, "port": 3456,
listen: "127.0.0.1", "listen": "127.0.0.1",
protocol: "vmess", "protocol": "vmess",
settings: { "settings": {
clients: [ "clients": [
{ {
id: "", // 填写你的 UUID "id": "", // 填写你的 UUID
level: 0, "level": 0,
email: "love@example.com", "email": "love@example.com"
}, }
], ]
},
streamSettings: {
network: "ws",
security: "none",
wsSettings: {
acceptProxyProtocol: true, // 提醒:若你用 Nginx/Caddy 等反代 WS需要删掉这行
path: "/vmessws", // 必须换成自定义的 PATH需要和分流的一致
},
}, },
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"acceptProxyProtocol": true, // 提醒:若你用 Nginx/Caddy 等反代 WS需要删掉这行
"path": "/vmessws" // 必须换成自定义的 PATH需要和分流的一致
}
}
} }
``` ```

View File

@ -74,91 +74,91 @@ acme.sh --install-cert -d example.com --fullchain-file /etc/ssl/xray/cert.pem --
## Xray 配置 ## Xray 配置
```json5 ```json
{ {
log: { "log": {
loglevel: "warning", "loglevel": "warning"
}, },
inbounds: [ "inbounds": [
{ {
port: 443, "port": 443,
protocol: "vless", "protocol": "vless",
settings: { "settings": {
clients: [ "clients": [
{ {
id: "UUID", "id": "UUID",
flow: "xtls-rprx-direct", "flow": "xtls-rprx-direct"
}, }
], ],
decryption: "none", "decryption": "none",
fallbacks: [ "fallbacks": [
{ {
name: "example.com", "name": "example.com",
path: "/vmessws", "path": "/vmessws",
dest: 5000, "dest": 5000,
xver: 1, "xver": 1
}, },
{ {
dest: 5001, "dest": 5001,
xver: 1, "xver": 1
}, },
{ {
alpn: "h2", "alpn": "h2",
dest: 5002, "dest": 5002,
xver: 1, "xver": 1
}, },
{ {
name: "blog.example.com", "name": "blog.example.com",
dest: 5003, "dest": 5003,
xver: 1, "xver": 1
}, },
{ {
name: "blog.example.com", "name": "blog.example.com",
alpn: "h2", "alpn": "h2",
dest: 5004, "dest": 5004,
xver: 1, "xver": 1
}
]
}, },
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"alpn": ["h2", "http/1.1"],
"certificates": [
{
"certificateFile": "/etc/ssl/xray/cert.pem",
"keyFile": "/etc/ssl/xray/privkey.key"
}
]
}
}
},
{
"listen": "127.0.0.1",
"port": 5000,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "UUID"
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"acceptProxyProtocol": true,
"path": "/vmessws"
}
}
}
], ],
}, "outbounds": [
streamSettings: {
network: "tcp",
security: "xtls",
xtlsSettings: {
alpn: ["h2", "http/1.1"],
certificates: [
{ {
certificateFile: "/etc/ssl/xray/cert.pem", "protocol": "freedom"
keyFile: "/etc/ssl/xray/privkey.key", }
}, ]
],
},
},
},
{
listen: "127.0.0.1",
port: 5000,
protocol: "vmess",
settings: {
clients: [
{
id: "UUID",
},
],
},
streamSettings: {
network: "ws",
wsSettings: {
acceptProxyProtocol: true,
path: "/vmessws",
},
},
},
],
outbounds: [
{
protocol: "freedom",
},
],
} }
``` ```
@ -192,7 +192,8 @@ acme.sh --install-cert -d example.com --fullchain-file /etc/ssl/xray/cert.pem --
如果使用 Caddy 就大可不必如此繁杂了,因为它**可以**在同一端口上同时监听 HTTP/1.1 和 h2c配置改动如下 如果使用 Caddy 就大可不必如此繁杂了,因为它**可以**在同一端口上同时监听 HTTP/1.1 和 h2c配置改动如下
```json5 ```json
{
"fallbacks": [ "fallbacks": [
{ {
"name": "example.com", "name": "example.com",
@ -210,6 +211,7 @@ acme.sh --install-cert -d example.com --fullchain-file /etc/ssl/xray/cert.pem --
"xver": 1 "xver": 1
} }
] ]
}
``` ```
## Nginx 配置 ## Nginx 配置

View File

@ -51,7 +51,8 @@
下面的入站配置示例,用大白话说就是:数据按照 `socks` 协议,通过 `10808` 端口,从本机 `127.0.0.1` 流入`Xray`。同时,`Xray` 将这个入站用 `[tag]` 命名为 `inbound-10808` 下面的入站配置示例,用大白话说就是:数据按照 `socks` 协议,通过 `10808` 端口,从本机 `127.0.0.1` 流入`Xray`。同时,`Xray` 将这个入站用 `[tag]` 命名为 `inbound-10808`
```json5 ```json
{
"inbounds": [ "inbounds": [
{ {
"tag": "inbound-10808", "tag": "inbound-10808",
@ -63,6 +64,7 @@
} }
} }
] ]
}
``` ```
**2.2 出站** **2.2 出站**
@ -73,7 +75,8 @@
下面的出站配置示例,用大白话说就是:数据按照 `VLESS` 协议,以 `tcp + xtls (direct)` 的方式、及其他相关设置,把流量发送给对应的 VPS。同时`Xray` 将这个出站用 `[tag]` 命名为 `proxy-out-vless` 下面的出站配置示例,用大白话说就是:数据按照 `VLESS` 协议,以 `tcp + xtls (direct)` 的方式、及其他相关设置,把流量发送给对应的 VPS。同时`Xray` 将这个出站用 `[tag]` 命名为 `proxy-out-vless`
```json5 ```json
{
"outbounds": [ "outbounds": [
{ {
"tag": "proxy-out-vless", "tag": "proxy-out-vless",
@ -103,6 +106,7 @@
} }
} }
] ]
}
``` ```
### 2.3 路由 ### 2.3 路由
@ -113,19 +117,19 @@
下面的路由配置示例,用大白话说就是:把所有通过 `[tag]="inbound-10808"` 入站流入 `Xray` 的流量,`100%` 全部流转导入 `[tag]="proxy-out-vless"` 的出站,没有任何分流或其他操作。 下面的路由配置示例,用大白话说就是:把所有通过 `[tag]="inbound-10808"` 入站流入 `Xray` 的流量,`100%` 全部流转导入 `[tag]="proxy-out-vless"` 的出站,没有任何分流或其他操作。
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
{ {
"type": "field", "type": "field",
"inboundTag": [ "inboundTag": ["inbound-10808"],
"inbound-10808"
],
"outboundTag": "proxy-out-vless" "outboundTag": "proxy-out-vless"
} }
] ]
} }
}
``` ```
至此,我们最开始设计的极简规则【客户端的 `Xray` 入站接收 APP 数据、在路由 100%转发给出站,并从出站流向 VPS】已经完成。 至此,我们最开始设计的极简规则【客户端的 `Xray` 入站接收 APP 数据、在路由 100%转发给出站,并从出站流向 VPS】已经完成。
@ -201,11 +205,12 @@
在上例的基础上,我们已经有了 `[proxy]` 的出站 `"proxy-out-vless"`,所以它保持不变。显而易见,我们需要加入两个新的出站方式:`[block]` 和 `[direct]`,如下: 在上例的基础上,我们已经有了 `[proxy]` 的出站 `"proxy-out-vless"`,所以它保持不变。显而易见,我们需要加入两个新的出站方式:`[block]` 和 `[direct]`,如下:
```json5 ```json
{
"outbounds": [ "outbounds": [
{ {
"tag": "proxy-out-vless", "tag": "proxy-out-vless"
...... // ... ...
}, },
{ {
"tag": "block", "tag": "block",
@ -216,6 +221,7 @@
"protocol": "freedom" "protocol": "freedom"
} }
] ]
}
``` ```
上面的配置用大白话翻译如下: 上面的配置用大白话翻译如下:
@ -228,33 +234,29 @@
接下来就是见证奇迹的时刻了,我们可以用【路由】的配置把这些连接起来! 接下来就是见证奇迹的时刻了,我们可以用【路由】的配置把这些连接起来!
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["geosite:category-ads-all"],
"geosite:category-ads-all"
],
"outboundTag": "block" "outboundTag": "block"
}, },
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["geosite:cn"],
"geosite:cn"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
}, },
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["geosite:geolocation-!cn"],
"geosite:geolocation-!cn"
],
"outboundTag": "proxy-out-vless" "outboundTag": "proxy-out-vless"
} }
] ]
} }
}
``` ```
为了理解这个配置文件,我们要稍微解释一下这里出现的几个新配置项: 为了理解这个配置文件,我们要稍微解释一下这里出现的几个新配置项:
@ -362,21 +364,23 @@
是不是,非常地简单? 是不是,非常地简单?
```json5 ```json
{
"outbounds": [ "outbounds": [
{ {
"tag": "direct-out", "tag": "direct-out",
"protocol": "freedom" "protocol": "freedom"
}, },
{ {
"tag": "proxy-out-vless", "tag": "proxy-out-vless"
...... // ... ...
}, },
{ {
"tag": "block", "tag": "block",
"protocol": "blackhole" "protocol": "blackhole"
} }
] ]
}
``` ```
此时,路由规则其实变成了: 此时,路由规则其实变成了:

View File

@ -50,36 +50,32 @@
上述配置如下: 上述配置如下:
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
// 指定子域名直连 // 指定子域名直连
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["full:direct.yourdomain.com"],
"full:direct.yourdomain.com"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
}, },
// 指定子域名转发VPS // 指定子域名转发VPS
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["full:proxy.yourdomain.com"],
"full:proxy.yourdomain.com"
],
"outboundTag": "proxy-out-vless" "outboundTag": "proxy-out-vless"
}, },
// 指定泛域名转发VPS // 指定泛域名转发VPS
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["yourdomain.com"],
"yourdomain.com"
],
"outboundTag": "proxy-out-vless" "outboundTag": "proxy-out-vless"
} }
] ]
} }
}
``` ```
### 5.2 基于 IP 文件分流:`geoip.dat` ### 5.2 基于 IP 文件分流:`geoip.dat`
@ -92,28 +88,26 @@
上述配置如下: 上述配置如下:
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
// 本机内部地址、局域网地址直连 // 本机内部地址、局域网地址直连
{ {
"type": "field", "type": "field",
"ip": [ "ip": ["geoip:private"],
"geoip:private"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
}, },
// 国内IP集直连 // 国内IP集直连
{ {
"type": "field", "type": "field",
"ip": [ "ip": ["geoip:cn"],
"geoip:cn"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
} }
] ]
} }
}
``` ```
### 5.3 基于指定 IP 地址分流 ### 5.3 基于指定 IP 地址分流
@ -125,28 +119,26 @@
上述配置如下: 上述配置如下:
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
// 指定IP地址直连 // 指定IP地址直连
{ {
"type": "field", "type": "field",
"ip": [ "ip": ["223.5.5.5"],
"223.5.5.5"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
}, },
// 指定IP地址转发VPS // 指定IP地址转发VPS
{ {
"type": "field", "type": "field",
"ip": [ "ip": ["1.1.1.1"],
"1.1.1.1"
],
"outboundTag": "proxy-out-vless" "outboundTag": "proxy-out-vless"
} }
] ]
} }
}
``` ```
### 5.4 基于协议类型分流:`[protocol]` 等 ### 5.4 基于协议类型分流:`[protocol]` 等
@ -157,20 +149,20 @@
你需要打开入站代理中的 `sniffing` 才能使用此种方式分流。 你需要打开入站代理中的 `sniffing` 才能使用此种方式分流。
::: :::
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
// 指定 BT 协议直连 // 指定 BT 协议直连
{ {
"type": "field", "type": "field",
"protocol": [ "protocol": ["bittorrent"],
"bittorrent"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
} }
] ]
} }
}
``` ```
### 5.5 基于更多条件的分流 ### 5.5 基于更多条件的分流
@ -205,7 +197,8 @@
`[1-block] --> [2-direct] --> [3-proxy] --> [4-first-outbound]` `[1-block] --> [2-direct] --> [3-proxy] --> [4-first-outbound]`
::: :::
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
@ -213,37 +206,26 @@
// 1.1 广告域名集屏蔽 // 1.1 广告域名集屏蔽
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["geosite:category-ads-all"],
"geosite:category-ads-all"
],
"outboundTag": "block" "outboundTag": "block"
}, },
// [2-direct 国内流量直连] // [2-direct 国内流量直连]
// 2.1 国内域名集、指定子域名直连 // 2.1 国内域名集、指定子域名直连
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["geosite:cn", "full:direct.yourdomain.com"],
"geosite:cn",
"full:direct.yourdomain.com"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
}, },
// 2.2 本机内部地址+局域网、国内IP、指定IP直连 // 2.2 本机内部地址+局域网、国内IP、指定IP直连
{ {
"type": "field", "type": "field",
"ip": [ "ip": ["geoip:private", "geoip:cn", "223.5.5.5"],
"geoip:private",
"geoip:cn",
"223.5.5.5"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
}, },
// 2.3 BT协议流量直连 // 2.3 BT协议流量直连
{ {
"type": "field", "type": "field",
"protocol": [ "protocol": ["bittorrent"],
"bittorrent"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
}, },
// [3-proxy 国外流量转发VPS] // [3-proxy 国外流量转发VPS]
@ -260,15 +242,14 @@
// 3.2 指定IP转发VPS // 3.2 指定IP转发VPS
{ {
"type": "field", "type": "field",
"ip": [ "ip": ["1.1.1.1"],
"1.1.1.1"
],
"outboundTag": "proxy-out-vless" "outboundTag": "proxy-out-vless"
} }
// [4-default-routing 第一条出站] // [4-default-routing 第一条出站]
// 没有匹配到任何规则的流量,默认使用第一条出站处理 // 没有匹配到任何规则的流量,默认使用第一条出站处理
] ]
} }
}
``` ```
此时,路由规则其实变成了: 此时,路由规则其实变成了:
@ -325,22 +306,20 @@
为了实现上面的目标,他写出了以下路由规则: 为了实现上面的目标,他写出了以下路由规则:
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
{ {
"type": "field", "type": "field",
"ip": [ "ip": ["223.5.5.5"],
"223.5.5.5" "domain": ["full:direct.yourdomain.com"],
],
"domain": [
"full:direct.yourdomain.com"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
} }
] ]
} }
}
``` ```
你能看出这里面的错误吗?乍一看,似乎是对的? 你能看出这里面的错误吗?乍一看,似乎是对的?
@ -357,26 +336,24 @@
正确示范,自然就是将不同的匹配依据独立出来: 正确示范,自然就是将不同的匹配依据独立出来:
```json5 ```json
{
"routing": { "routing": {
"domainStrategy": "AsIs", "domainStrategy": "AsIs",
"rules": [ "rules": [
{ {
"type": "field", "type": "field",
"ip": [ "ip": ["223.5.5.5"],
"223.5.5.5"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
}, },
{ {
"type": "field", "type": "field",
"domain": [ "domain": ["full:direct.yourdomain.com"],
"full:direct.yourdomain.com"
],
"outboundTag": "direct-out" "outboundTag": "direct-out"
} }
] ]
} }
}
``` ```
其实,第 6 点已经是我整理过的规则了,原则就是【相同的匹配依据可以合并,不同的匹配依据保持独立】。 其实,第 6 点已经是我整理过的规则了,原则就是【相同的匹配依据可以合并,不同的匹配依据保持独立】。