科学上网 – xray

生成UUID

/usr/bin/xray/xray uuid
/usr/bin/xray/xray uuid -i "custom string"

上面生成随机uuid,下面通过字符串生成自定义uuid。

创建log目录和配置文件

mkdir /var/log/xray
chown -R xray:xray /var/log/xray/
vim /etc/xray/config.json
// Config file of XRay Server.
{
  "log": {
    // By default, XRay writes log to stdout.
    "access": "/var/log/xray/access",
    "error": "/var/log/xray/error",
    // Log level, one of "debug", "info", "warning", "error", "none"
    "loglevel": "warning"
  },
  // Enable internal statistics.
  "stats": {},

  "dns": {
    "servers": [
      "8.8.8.8",
      "8.8.4.4",
    {
        "address": "https://1.1.1.1/dns-query",
    "domains": [
      "geosite:openai"
    ],
    "skipFallback": true,
    "queryStrategy": "UseIPv6"
    },
      "localhost"
    ],
    "queryStrategy": "UseIP",
    "tag": "dns_inbound"
  },

  "inbounds": [
  {
    "listen": "127.0.0.1",
    "port": 7700,
    "tag": "proxy",
    "protocol": "vless",

    "settings": {
      "clients": [
        {"id": "put your uuid here", "level": 0, "email": "[email protected]" },
        {"id": "put your uuid here", "level": 0, "email": "[email protected]" }
      ],
      "decryption": "none"
    },

    "streamSettings": {
      "network": "ws",
      "wsSettings": { "path": "/custom-path" }
    }
  }
  ],

  "outbounds": [{
    "protocol": "freedom",
    "settings": {},
    "tag": "direct"
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],

  "routing": {
    "domainStrategy": "AsIs",
    "rules":[
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      },
      {
        "type": "field",
        "domain": ["geosite:category-ads"],
        "outboundTag": "blocked"
      },
      {
        "type": "field",
        "domain": ["geosite:tiktok"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "domain": ["geosite:cn"],
        "outboundTag": "blocked"
      },
      {
        "type": "field",
        "domain": ["geoip:cn"],
        "outboundTag": "blocked"
      },
      {
        "type": "field",
        "inboundTag": ["proxy"],
        "outboundTag": "direct"
      }
    ]
  },

  "policy": {
    "levels": {
      "0": {
        "statsUserUplink": true,
        "statsUserDownlink": true
      }
    },
    "system": {
      "statsInboundUplink": true,
      "statsInboundDownlink": true
    }
  }
}

这里配置使用VLESS的入站协议,自定义了处理path路径,后面搭配HTTPS使用;配置了路由,将入站数据按需求由不同的出站连接发出,以达到按需代理的目的。

发表评论

error: Content is protected !!