安装Xray
根据您的操作系统进行安装:
- Windows:下载并安装Xray,完成后会自动生成
xray.json配置文件。 - Linux:使用包管理器安装Xray,如
sudo apt-get install xray。 - macOS:从官方网站下载并安装。
- Docker:使用镜像
xray/xray,运行命令docker run -v /xray:/xray xray/xray。
配置Xray
编辑xray.json文件,根据需求添加规则:
{
"in": {
"listener": "127...1:108",
"auth": "xray",
"out": "...:808",
"log": "/var/log/xray/xray.log",
"maxconnect": 100000,
"minconnect": 100,
"fallback": [
{
"dest": "...:80",
"to": "1.1.1.1:80"
}
]
},
"out": {
" listener": "127...1:1081"
},
"rules": [
{
"name": "Allow Google",
"src": ".../",
"dst": "google.com",
"action": "allow",
"start": 1,
"end": 1
},
{
"name": "Block YouTube",
"src": ".../",
"dst": "youtube.com",
"action": "block",
"start": 1,
"end": 1
},
{
"name": "Throttle IP",
"src": ".../",
"dst": ".../",
"action": "throttle",
"start": 1,
"end": 1,
"count": 10,
"duration": 86400
}
],
"dns": {
"servers": ["8.8.8.8", "8.8.4.4"],
"domains": ["*.google.com", "www.youtube.com"]
},
"websocket": {
"enabled": true,
"listen": "127...1:8088",
"fallback": "ws://1.1.1.1:80/ws"
},
"plugins": [
{
"name": "adblock",
"version": "1.."
}
]
}
启动Xray
在命令行运行xray start,然后在浏览器中配置代理设置,使用本地代理服务器地址..1:108。
测试配置
使用curl测试被限制的网址,如curl -I http://www.youtube.com,查看返回码是否为403或502,确认规则生效。
安装插件
通过命令安装插件,例如广告拦截:xray plugin install adblock,然后重启服务。
备份配置
将xray.json备份到安全的位置,如云存储或本地备仆。
使用Xray的Web界面
访问http://127...1:1081,使用默认管理员账号“xray”和密码“xray”进行管理。
监控日志
查看日志文件,了解网络流量情况,并根据需要调整规则。
通过以上步骤,您可以配置一个符合需求的Xray节点,管理网络访问权限和流量。









