说明

使用的项目地址:https://github.com/XTLS/Xray-core

一键脚本:https://github.com/XTLS/Xray-install

各种类型的配置文件参考:https://github.com/XTLS/Xray-examples

开始

脚本安装

1
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install

安装的目录情况

installed: /etc/systemd/system/xray.service
installed: /etc/systemd/system/xray@.service

installed: /usr/local/bin/xray
installed: /usr/local/etc/xray/*.json

installed: /usr/local/share/xray/geoip.dat
installed: /usr/local/share/xray/geosite.dat

installed: /var/log/xray/access.log
installed: /var/log/xray/error.log

修改配置文件

1
vim /usr/local/etc/xray/config.json

文件内容如下,自行修改监听端口,uuid 还有路径

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
// 常用的config文件,不论服务器端还是客户端,都有以下5个部分
// ┌─ 1_log 日志设置
// ├─ 2_dns DNS-设置
// ├─ 3_routing 分流设置
// ├─ 4_inbounds 入站设置 - 什么流量可以流入Xray
// └─ 5_outbounds 出站设置 - 流出Xray的流量往哪里去

{
"log": {
"loglevel": "warning", // 内容从少到多: "none", "error", "warning", "info", "debug"
"access": "/var/log/xray/access.log", // 访问记录
"error": "/var/log/xray/error.log" // 错误记录
},
"dns": {
"servers": ["8.8.8.8", "localhost"]
},
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"ip": [
"geoip:private" // 分流条件:geoip文件内,名为"private"的规则(本地)
],
"outboundTag": "block" // 分流条件:geoip文件内,名为"private"的规则(本地)
}
]
},
"inbounds": [
{
"listen": "0.0.0.0",
// 监听端口
"port": 33366,
"protocol": "vmess",
"settings": {
"clients": [
{
// uuid
"id": "5f890a31-27b0-463e-a93f-6a46b9f963a1"
}
]
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
// 路径
"path": "/video"
}
}
}
],
"outbounds": [
{
"protocol": "freedom", // freedom就是对外直连
"tag": "direct"
},
{
"protocol": "blackhole", // blackhole协议就是把流量导入到黑洞里(屏蔽)
"tag": "block"
}
]
}

配置 Nginx 反向代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server
{
listen 80;
listen [::]:80;
# 如果想加入免流的话,可以在这里填入混淆host;server_name 会与 混淆host 匹配
# 如果不需要的话,填入服务器域名即可
server_name pull.free.video.10010.com;

# 和上面的路径对应
location /video {
proxy_pass http://127.0.0.1:33366;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
location / {
try_files $uri $uri/ =404;
}
}