mirror of
https://github.com/XTLS/Xray-docs-next.git
synced 2026-09-28 09:58:06 +03:00
Fix json format
close https://github.com/XTLS/Xray-docs-next/pull/83 Thanks: @Johnshall
This commit is contained in:
@@ -201,7 +201,7 @@
|
||||
4. 将下面的文件全部复制进去,并将之前生成的`UUID`填入第 61 行 `"id": "",` 之中。(填好之后的样子是 `"id": "uuiduuid-uuid-uuid-uuid-uuiduuiduuid"`
|
||||
),本文的这个配置文件中增加了我的各种啰嗦注解,以方便你理解每一个配置模块的功能是什么。
|
||||
|
||||
```json5
|
||||
```json
|
||||
// REFERENCE:
|
||||
// https://github.com/XTLS/Xray-examples
|
||||
// https://xtls.github.io/config/
|
||||
@@ -213,92 +213,92 @@
|
||||
// └─ 5_outbounds 出站设置 - 流出 Xray 的流量往哪里去
|
||||
{
|
||||
// 1\_日志设置
|
||||
log: {
|
||||
loglevel: "warning", // 内容从少到多: "none", "error", "warning", "info", "debug"
|
||||
access: "/home/vpsadmin/xray_log/access.log", // 访问记录
|
||||
error: "/home/vpsadmin/xray_log/error.log", // 错误记录
|
||||
"log": {
|
||||
"loglevel": "warning", // 内容从少到多: "none", "error", "warning", "info", "debug"
|
||||
"access": "/home/vpsadmin/xray_log/access.log", // 访问记录
|
||||
"error": "/home/vpsadmin/xray_log/error.log" // 错误记录
|
||||
},
|
||||
// 2_DNS 设置
|
||||
dns: {
|
||||
servers: [
|
||||
"dns": {
|
||||
"servers": [
|
||||
"https+local://1.1.1.1/dns-query", // 首选 1.1.1.1 的 DoH 查询,牺牲速度但可防止 ISP 偷窥
|
||||
"localhost",
|
||||
],
|
||||
"localhost"
|
||||
]
|
||||
},
|
||||
// 3*分流设置
|
||||
routing: {
|
||||
domainStrategy: "AsIs",
|
||||
rules: [
|
||||
"routing": {
|
||||
"domainStrategy": "AsIs",
|
||||
"rules": [
|
||||
// 3.1 防止服务器本地流转问题:如内网被攻击或滥用、错误的本地回环等
|
||||
{
|
||||
type: "field",
|
||||
ip: [
|
||||
"geoip:private", // 分流条件:geoip 文件内,名为"private"的规则(本地)
|
||||
"type": "field",
|
||||
"ip": [
|
||||
"geoip:private" // 分流条件:geoip 文件内,名为"private"的规则(本地)
|
||||
],
|
||||
outboundTag: "block", // 分流策略:交给出站"block"处理(黑洞屏蔽)
|
||||
"outboundTag": "block" // 分流策略:交给出站"block"处理(黑洞屏蔽)
|
||||
},
|
||||
// 3.2 屏蔽广告
|
||||
{
|
||||
type: "field",
|
||||
domain: [
|
||||
"geosite:category-ads-all", // 分流条件:geosite 文件内,名为"category-ads-all"的规则(各种广告域名)
|
||||
"type": "field",
|
||||
"domain": [
|
||||
"geosite:category-ads-all" // 分流条件:geosite 文件内,名为"category-ads-all"的规则(各种广告域名)
|
||||
],
|
||||
outboundTag: "block", // 分流策略:交给出站"block"处理(黑洞屏蔽)
|
||||
},
|
||||
],
|
||||
"outboundTag": "block" // 分流策略:交给出站"block"处理(黑洞屏蔽)
|
||||
}
|
||||
]
|
||||
},
|
||||
// 4*入站设置
|
||||
// 4.1 这里只写了一个最简单的 vless+xtls 的入站,因为这是 Xray 最强大的模式。如有其他需要,请根据模版自行添加。
|
||||
inbounds: [
|
||||
"inbounds": [
|
||||
{
|
||||
port: 443,
|
||||
protocol: "vless",
|
||||
settings: {
|
||||
clients: [
|
||||
"port": 443,
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
id: "", // 填写你的 UUID
|
||||
flow: "xtls-rprx-direct",
|
||||
level: 0,
|
||||
email: "vpsadmin@yourdomain.com",
|
||||
},
|
||||
"id": "", // 填写你的 UUID
|
||||
"flow": "xtls-rprx-direct",
|
||||
"level": 0,
|
||||
"email": "vpsadmin@yourdomain.com"
|
||||
}
|
||||
],
|
||||
decryption: "none",
|
||||
fallbacks: [
|
||||
"decryption": "none",
|
||||
"fallbacks": [
|
||||
{
|
||||
dest: 80, // 默认回落到防探测的代理
|
||||
},
|
||||
],
|
||||
"dest": 80 // 默认回落到防探测的代理
|
||||
}
|
||||
]
|
||||
},
|
||||
streamSettings: {
|
||||
network: "tcp",
|
||||
security: "xtls",
|
||||
xtlsSettings: {
|
||||
allowInsecure: false, // 正常使用应确保关闭
|
||||
minVersion: "1.2", // TLS 最低版本设置
|
||||
alpn: ["http/1.1"],
|
||||
certificates: [
|
||||
"streamSettings": {
|
||||
"network": "tcp",
|
||||
"security": "xtls",
|
||||
"xtlsSettings": {
|
||||
"allowInsecure": false, // 正常使用应确保关闭
|
||||
"minVersion": "1.2", // TLS 最低版本设置
|
||||
"alpn": ["http/1.1"],
|
||||
"certificates": [
|
||||
{
|
||||
certificateFile: "/home/vpsadmin/xray_cert/xray.crt",
|
||||
keyFile: "/home/vpsadmin/xray_cert/xray.key",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"certificateFile": "/home/vpsadmin/xray_cert/xray.crt",
|
||||
"keyFile": "/home/vpsadmin/xray_cert/xray.key"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
// 5*出站设置
|
||||
outbounds: [
|
||||
"outbounds": [
|
||||
// 5.1 第一个出站是默认规则,freedom 就是对外直连(vps 已经是外网,所以直连)
|
||||
{
|
||||
tag: "direct",
|
||||
protocol: "freedom",
|
||||
"tag": "direct",
|
||||
"protocol": "freedom"
|
||||
},
|
||||
// 5.2 屏蔽规则,blackhole 协议就是把流量导入到黑洞里(屏蔽)
|
||||
{
|
||||
tag: "block",
|
||||
protocol: "blackhole",
|
||||
},
|
||||
],
|
||||
"tag": "block",
|
||||
"protocol": "blackhole"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
- 请将 `serverName` 替换成你的真实域名
|
||||
- 各个配置模块的说明我都已经(很啰嗦的)放在对应的配置点上了
|
||||
|
||||
```json5
|
||||
```json
|
||||
// REFERENCE:
|
||||
// https://github.com/XTLS/Xray-examples
|
||||
// https://xtls.github.io/config/
|
||||
@@ -114,135 +114,135 @@
|
||||
{
|
||||
// 1_日志设置
|
||||
// 注意,本例中我默认注释掉了日志文件,因为windows, macOS, Linux 需要写不同的路径,请自行配置
|
||||
log: {
|
||||
"log": {
|
||||
// "access": "/home/local/xray_log/access.log", // 访问记录
|
||||
// "error": "/home/local/xray_log/error.log", // 错误记录
|
||||
loglevel: "warning", // 内容从少到多: "none", "error", "warning", "info", "debug"
|
||||
"loglevel": "warning" // 内容从少到多: "none", "error", "warning", "info", "debug"
|
||||
},
|
||||
|
||||
// 2_DNS设置
|
||||
dns: {
|
||||
servers: [
|
||||
"dns": {
|
||||
"servers": [
|
||||
// 2.1 国外域名使用国外DNS查询
|
||||
{
|
||||
address: "1.1.1.1",
|
||||
domains: ["geosite:geolocation-!cn"],
|
||||
"address": "1.1.1.1",
|
||||
"domains": ["geosite:geolocation-!cn"]
|
||||
},
|
||||
// 2.2 国内域名使用国内DNS查询,并期待返回国内的IP,若不是国内IP则舍弃,用下一个查询
|
||||
{
|
||||
address: "223.5.5.5",
|
||||
domains: ["geosite:cn"],
|
||||
expectIPs: ["geoip:cn"],
|
||||
"address": "223.5.5.5",
|
||||
"domains": ["geosite:cn"],
|
||||
"expectIPs": ["geoip:cn"]
|
||||
},
|
||||
// 2.3 作为2.2的备份,对国内网站进行二次查询
|
||||
{
|
||||
address: "114.114.114.114",
|
||||
domains: ["geosite:cn"],
|
||||
"address": "114.114.114.114",
|
||||
"domains": ["geosite:cn"]
|
||||
},
|
||||
// 2.4 最后的备份,上面全部失败时,用本机DNS查询
|
||||
"localhost",
|
||||
],
|
||||
"localhost"
|
||||
]
|
||||
},
|
||||
|
||||
// 3_分流设置
|
||||
// 所谓分流,就是将符合否个条件的流量,用指定`tag`的出站协议去处理(对应配置的5.x内容)
|
||||
routing: {
|
||||
domainStrategy: "AsIs",
|
||||
rules: [
|
||||
"routing": {
|
||||
"domainStrategy": "AsIs",
|
||||
"rules": [
|
||||
// 3.1 广告域名屏蔽
|
||||
{
|
||||
type: "field",
|
||||
domain: ["geosite:category-ads-all"],
|
||||
outboundTag: "block",
|
||||
"type": "field",
|
||||
"domain": ["geosite:category-ads-all"],
|
||||
"outboundTag": "block"
|
||||
},
|
||||
// 3.2 国内域名直连
|
||||
{
|
||||
type: "field",
|
||||
domain: ["geosite:cn"],
|
||||
outboundTag: "direct",
|
||||
"type": "field",
|
||||
"domain": ["geosite:cn"],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
// 3.3 国内IP直连
|
||||
{
|
||||
type: "field",
|
||||
ip: ["geoip:cn", "geoip:private"],
|
||||
outboundTag: "direct",
|
||||
"type": "field",
|
||||
"ip": ["geoip:cn", "geoip:private"],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
// 3.4 国外域名代理
|
||||
{
|
||||
type: "field",
|
||||
domain: ["geosite:geolocation-!cn"],
|
||||
outboundTag: "proxy",
|
||||
},
|
||||
"type": "field",
|
||||
"domain": ["geosite:geolocation-!cn"],
|
||||
"outboundTag": "proxy"
|
||||
}
|
||||
// 3.5 默认规则
|
||||
// 在Xray中,任何不符合上述路由规则的流量,都会默认使用【第一个outbound(5.1)】的设置,所以一定要把转发VPS的outbound放第一个
|
||||
],
|
||||
]
|
||||
},
|
||||
|
||||
// 4_入站设置
|
||||
inbounds: [
|
||||
"inbounds": [
|
||||
// 4.1 一般都默认使用socks5协议作本地转发
|
||||
{
|
||||
tag: "socks-in",
|
||||
protocol: "socks",
|
||||
listen: "127.0.0.1", // 这个是通过socks5协议做本地转发的地址
|
||||
port: 10800, // 这个是通过socks5协议做本地转发的端口
|
||||
settings: {
|
||||
udp: true,
|
||||
},
|
||||
"tag": "socks-in",
|
||||
"protocol": "socks",
|
||||
"listen": "127.0.0.1", // 这个是通过socks5协议做本地转发的地址
|
||||
"port": 10800, // 这个是通过socks5协议做本地转发的端口
|
||||
"settings": {
|
||||
"udp": true
|
||||
}
|
||||
},
|
||||
// 4.2 有少数APP不兼容socks协议,需要用http协议做转发,则可以用下面的端口
|
||||
{
|
||||
tag: "http-in",
|
||||
protocol: "http",
|
||||
listen: "127.0.0.1", // 这个是通过http协议做本地转发的地址
|
||||
port: 10801, // 这个是通过http协议做本地转发的端口
|
||||
},
|
||||
"tag": "http-in",
|
||||
"protocol": "http",
|
||||
"listen": "127.0.0.1", // 这个是通过http协议做本地转发的地址
|
||||
"port": 10801 // 这个是通过http协议做本地转发的端口
|
||||
}
|
||||
],
|
||||
|
||||
// 5_出站设置
|
||||
outbounds: [
|
||||
"outbounds": [
|
||||
// 5.1 默认转发VPS
|
||||
// 一定放在第一个,在routing 3.5 里面已经说明了,这等于是默认规则,所有不符合任何规则的流量都走这个
|
||||
{
|
||||
tag: "proxy",
|
||||
protocol: "vless",
|
||||
settings: {
|
||||
vnext: [
|
||||
"tag": "proxy",
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
address: "a-name.yourdomain.com", // 替换成你的真实域名
|
||||
port: 443,
|
||||
users: [
|
||||
"address": "a-name.yourdomain.com", // 替换成你的真实域名
|
||||
"port": 443,
|
||||
"users": [
|
||||
{
|
||||
id: "uuiduuid-uuid-uuid-uuid-uuiduuiduuid", // 和服务器端的一致
|
||||
flow: "xtls-rprx-direct", // Windows, macOS 同学保持这个不变
|
||||
"id": "uuiduuid-uuid-uuid-uuid-uuiduuiduuid", // 和服务器端的一致
|
||||
"flow": "xtls-rprx-direct", // Windows, macOS 同学保持这个不变
|
||||
// "flow": "xtls-rprx-splice", // Linux和安卓同学请改成Splice性能更强
|
||||
encryption: "none",
|
||||
level: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
streamSettings: {
|
||||
network: "tcp",
|
||||
security: "xtls",
|
||||
xtlsSettings: {
|
||||
serverName: "a-name.yourdomain.com", // 替换成你的真实域名
|
||||
allowInsecure: false, // 禁止不安全证书
|
||||
},
|
||||
"encryption": "none",
|
||||
"level": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "tcp",
|
||||
"security": "xtls",
|
||||
"xtlsSettings": {
|
||||
"serverName": "a-name.yourdomain.com", // 替换成你的真实域名
|
||||
"allowInsecure": false // 禁止不安全证书
|
||||
}
|
||||
}
|
||||
},
|
||||
// 5.2 用`freedom`协议直连出站,即当routing中指定'direct'流出时,调用这个协议做处理
|
||||
{
|
||||
tag: "direct",
|
||||
protocol: "freedom",
|
||||
"tag": "direct",
|
||||
"protocol": "freedom"
|
||||
},
|
||||
// 5.3 用`blackhole`协议屏蔽流量,即当routing中指定'block'时,调用这个协议做处理
|
||||
{
|
||||
tag: "block",
|
||||
protocol: "blackhole",
|
||||
},
|
||||
],
|
||||
"tag": "block",
|
||||
"protocol": "blackhole"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user