页面

2024年7月7日星期日

x-ui多用户合租方案

 

前提条件

1. 拥有一台墙外vps
2. 一个域名(本例以挂靠cloudflare上的域名为例)

1、HostVDS上创建vps时需要创建SSH密钥

在Windows中,打开PowerShell
输入以下命令生成一个新的SSH密钥对:
ssh-keygen -t rsa -b 2048 -C "your_email@example.com"
其中,-t rsa 指定使用RSA算法,-b 2048 指定密钥长度为2048位,-C "your_email@example.com" 是一个注释,可以使用你的电子邮件地址。
系统会提示你输入文件名和保存位置。默认情况下,
密钥对会保存在~/.ssh/id_rsa(私钥)和~/.ssh/id_rsa.pub(公钥)文件中。
你可以按Enter键使用默认位置,或者输入其他路径。

上传刚才创建的 id_rsa.pub 文件到HostVDS

2、安装x-ui:

3、设置域名
在cloudflare上设置2个子域名,指向服务器ip
xui.你的域名
199.你的域名

4、获取Cloudflare Global API Key
导航:
域名-->概述-->获取你的API令牌



5、申请域名证书
x-ui
选择16. 一键申请SSL证书(acme申请)
按步骤填写即可
2个域名都设置证书,需要跑2次。

6、x-ui面板设置
1)设置页面证书


2)xray相关设置

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    }
  ],
  "policy": {
         "levels": {
      "0": {
        "handshake": 10,
        "connIdle": 100,
        "uplinkOnly": 2,
        "downlinkOnly": 3,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 10240
      }
   },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true,
      "statsOutboundUplink": false,
     "statsOutboundDownlink": false
    }
  },
  "routing": {
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      }
    ]
  },
  "stats": {}
}