3X-UI 是一款基于 Web 的图形用户界面(GUI)工具,主要用于管理和配置 Xray 服务器。它是 x-ui 的一个分支或改进版本,旨在提供更丰富的功能和更好的用户体验。3X-UI 同样用于简化 Xray 服务器的配置和管理,适用于科学上网、流量加密和代理转发等场景。

1. 功能介绍

  • 多用户管理:支持创建和管理多个用户,可以为每个用户设置独立的流量限制、过期时间等。
  • 多协议支持:支持多种代理协议,如 VMess、VLESS、Trojan、Shadowsocks 等。
  • 流量统计与监控:提供实时流量统计功能,方便管理员监控用户流量使用情况。
  • 日志管理:支持查看详细的连接日志和错误日志,便于排查问题。
  • SSL 证书管理:支持自动申请和管理 SSL 证书,简化 HTTPS 配置。
  • 自动化功能:支持自动更新 Xray 核心和面板,减少手动维护成本。
  • 多服务器管理:支持同时管理多个 Xray 服务器,方便集中管理。
  • 自定义配置:提供高级配置选项,满足个性化需求。
  • 更多高级配置项,详见该项目的 GitHub:点击访问 3x-ui

2. 准备工作

VPS 一台重置好主流的操作系统 (Almalinux 8+、Ubuntu 16+、Debian 8+)

域名一个,做好相关的解析,若是需要套用 CDN,请托管域名到 cloudflare

3. 获取一个海外 vps

这是使用的是一台Racknerd VPS

配置:3 vCore 2 GB RAM

本教教程使用的操作系统为: Almalinux 8

4. 安装 3X-UI 面板

1
2
3
4
5

dnf update

bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)

3X-UI 的安装比 X-UI 简洁,不需要输入太多信息和人工干预,他会采用一些默认值和随即值,如果用户需要一些关键信息,使用系统提供的指令即可。

例如要查看登陆信息,只需要使用x-ui settings命令即可。 由于 webBasePath 采用了随机字符串,安全性比 X-UI 也有增强。

1
2
3
4
5
6
7
8
9
10
11
12
13

$ x-ui settings

The OS release is: almalinux
[INF] current panel settings as follows:
Warning: Panel is not secure with SSL
username: sdasfaf
password: asdfadfsaf
port: 37164
webBasePath: /aasdfasdfwrwer/
Access URL: http://xx.xx.xx.xx:37164/webBasePath: /aasdfasdfwrwer/
/

放行端口 3X-UI 监听端口,否则从外部无法访问 3X-UI

1
2
3
4
5
6
7
8


# 安装完成后需要放开3X-UI 管理面板所监听的端口,我在安装时设置的是80端口,所以需要放开80端口

sudo firewall-cmd --add-port=37164/tcp --permanent

sudo firewall-cmd --reload

此时已经可以访问 3X-UI 了

使用浏览器打开 http://xx.xx.xx.xx:37164/aasdfasdfwrwer/ 即可看到 3X-UI 而管理页面,登陆使用x-ui settings命令打印出的用户和密码.

但是 http 协议是不安全的协议,很容易泄漏敏感信息,下面为 3X-UI 配置 https 安全访问

5. 安装 nginx

3X-UI 自带的 https 配置命令不是很好用,所以这里安装 nginx, 然后让 ngix 反向代理 3x-ui, 然后在 nginx 上配置 ssl 证书,从而实现 https 安全访问 3x-ui

1
2
3
4
5
6
7
8
9

sudo dnf install nginx

# 防火墙放行80和443端口
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https

sudo systemctl reload firewalld

6. 申请 SSL 证书

无论 X-UI 还是 3X-UI 的证书管理功能都不是很方便,而且经常会遇到各种 bug, 所以这里的证书采用 acme.sh 结合手动管理的方式来配置证书。

首先安装 acme.sh

1
2
3
4
5
6
7

dnf install -y curl socat tar

curl https://get.acme.sh | sh

source ~/.bashrc

申请证书

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# 如果3X-UI监听在80端口上,需要先暂停一下x-ui,

sudo systemctl stop nginx

# 创建文件用于存放证书
mkdir -p /etc/nginx/certs/

# ZeroSSL 的 retryafter 时间过长,您可以切换到 Let’s Encrypt CA。
acme.sh --set-default-ca --server letsencrypt

# 使用acme.sh申请证书
acme.sh --issue --standalone -d www.example.com --force


sudo systemctl start nginx

安装证书

1
2
3
4
5
6
7
8
9
10
11
12


# 创建文件用于存放证书
mkdir -p /etc/nginx/certs/

systemctl start nginx

acme.sh --installcert -d www.example.com \
--key-file /etc/nginx/certs/www.example.com.key \
--fullchain-file /etc/nginx/certs/www.example.com.crt \
--reloadcmd "systemctl reload nginx" --ecc

修改 nginx 配置

/etc/nginx/nginx.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

# Settings for a TLS enabled server.
server {
listen 80;
server_name www.example.com;
rewrite ^(.*)$ https://$host$1 permanent;
}

server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
server_name www.example.com;
root /usr/share/nginx/html;
http2 on;

ssl_certificate "/etc/nginx/certs/www.example.com.crt";
ssl_certificate_key "/etc/nginx/certs/www.example.com.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /aasdfasdfwrwer {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:37164/aasdfasdfwrwer;
}

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

修改完 nginx 配置后,重启 nginx 服务器

1
2
3
4
5
# 检查ngix配置
nginx -t

# 重启nginx服务器
sudo systemctl restart nginx

此时使用 https 的方式访问 3X-UI 了 https://xx.xx.xx.xx:37164/aasdfasdfwrwer/

7. 节点配置及功能讲解

可以配置一个简单的 vmess(tcp)类型节点测试一下。

7.1. 配置 vmess(tcp)类型节点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
启用: 开启
备注: vmess_node 1
协议: vmess
监听 IP: 留空 ---留空表示监听所有ip
端口: 32061
总流量(GB): 0
到期时间:2025-12-31
传输:TCP (RAW)
Proxy protoc0l: 不开启
Http 伪装:不开启
Sockopt: 不开启
tls: 不开启
External Proxy: 不开启
安全: 无
Sniffing: 不开启

8. 参考文档

3x-ui 安装指南+搭建 reality+申请 ssl 证书