要设置Xray只允许1.1.1.1访问,您需要在Xray配置文件中添加以下内容:

{
  "inbounds": [
    {
      "port": 8080,  // 这里是您的端口号,根据您自己的实际情况进行修改
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",  // 这里是您的客户端ID,根据您自己的实际情况进行修改
            "level": 0,
            "alterId": 64
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "tcpSettings": {
          "header": {
            "type": "http",
            "request": {
              "version": "1.1",
              "method": "GET",
              "path": ["/"],
              "headers": {
                "Host": ["www.baidu.com"],
                "User-Agent": ["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"],
                "Accept-Encoding": ["gzip, deflate"],
                "Connection": ["keep-alive"]
              }
            },
            "response": {
              "version": "1.1",
              "status": "200",
              "reason": "OK",
              "headers": {
                "Content-Type": ["application/octet-stream"],
                "Transfer-Encoding": ["chunked"],
                "Connection": ["keep-alive"],
                "X-Content-Type-Options": ["nosniff"]
              }
            }
          }
        }
      },
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "tag": "proxy"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    }
  ],
  "routing": {
    "rules": [
      {
        "type": "field",
        "outboundTag": "direct",
        "ip": ["geoip:private"]
      },
      {
        "type": "field",
        "outboundTag": "proxy",
        "ip": ["1.1.1.1"]
      }
    ]
  }
}

请注意,您需要将上面的代码中的端口号、客户端ID以及其他设置根据您自己的实际情况进行修改。另外,上面的代码是基于V2Ray的VMess协议进行配置的,如果您使用其他协议,可能会有所不同


原文地址: https://www.cveoy.top/t/topic/fUwK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录