跳转到内容

Xray安装

一个代理软件

Terminal window
bash <(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh) install

目录配置文件目录在/usr/local/etc/xray/config.json

{
"log": {
"loglevel": "error"
//"error": "/usr/local/etc/xray/xray_error.log" // 错误记录
},
"inbounds": [
{
"port": 2022, # 可以换成其他端口
"protocol": "vless",
"settings": {
"clients": [
{
"id": "**", // 填写UUID,可以使用xray uuid生成
"level": 1
}
],
"decryption": "none",
"fallbacks": [
{
"dest":80 // 回落配置,可以直接转到其他网站,例如"www.baidu.com:80"
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"alpn": [
"http/1.1"
],
"certificates": [
{
"certificateFile": "/root/certs/example.com/fullchain.pem", // 换成你的证书,绝对路径
"keyFile": "/root/certs/example.com/key.pem" // 换成你的私钥,绝对路径
}
]
},
"fingerprint": "chrome"
}
},
{
"port": 2024, // 可以换成其他端口
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "**", // 填写UUID,可以使用xray uuid生成
"level": 1
}
]
},
"streamSettings": {
"network": "ws",
"tlsSettings": {
"alpn": [
"http/1.1"
]
},
"wsSettings": {
"path": "/**"
}
},
"sniffing": {
"enabled": true, // 开启流量探测,用于分流或屏蔽 BT 协议。
"destOverride": [ // 当流量为指定类型时,按其中包括的目标地址重置当前连接的目标。
"http",
"tls",
"quic"
]
}
},
{
"port": 2023, // 可以换成其他端口
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "**", // 填写UUID,可以使用xray uuid生成
"level": 1
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"alpn": [
"http/1.1"
],
"certificates": [
{
"certificateFile": "/root/certs/example.com/fullchain.pem", // 换成你的证书,绝对路径
"keyFile": "/root/certs/example.com/key.pem" // 换成你的私钥,绝对路径
}
]
},
"wsSettings": {
"path": "/**"
}
},
"sniffing": {
"enabled": true, // 开启流量探测,用于分流或屏蔽 BT 协议。
"destOverride": [ // 当流量为指定类型时,按其中包括的目标地址重置当前连接的目标。
"http",
"tls",
"quic"
]
}
},
{
"tag": "naiveproxy_in",
"port": 2025,
"listen": "127.0.0.1",
"protocol": "socks"
}
],
"outbounds": [
{
"protocol": "freedom"
},
{ // 出站 路由标记示例。WARP WireGuard 双栈非全局路由分流
"tag": "WARP_x",
"protocol": "freedom",
"streamSettings": {
"sockopt": {
"mark": 51888 // 路由标记
}
},
"settings": {
"domainStrategy": "UseIP" // "UseIP"(双栈自适应)、”UseIPv4”(IPv4 优先)、”UseIPv4”(Pv6 优先)
}
},
{
"tag":"WARP_SOCK",
"protocol":"socks",
"settings":{
"servers": [
{
"address": "127.0.0.1",
"port": 40000
}
],
"domainStrategy": "UserIP"
}
}
],
"routing":{
"domainStrategy":"AsIs",
"rules":[
{
"type":"field",
"domain":[
"domain:openai.com",
"domain:ai.com",
"geosite:netflix",
"domain:netflix.com",
"domain:netflix.net",
"domain:nflximg.net",
"domain:nflxvideo.net",
"domain:nflxso.net",
"domain:nflxext.com"
],
"outboundTag":"WARP_SOCK"
}
]
}
}
  • http 代理服务与 http 请求不一致。所以直接通过 xray 配置的 http inbound 不可以直接处理 http 请求的。
  • 权限问题
    无法打开证书文件
    • 修改/ect/systemd/system/xray.service 中的 user 为 root
    • 确保证书文件目录拥有执行 x 权限