3x-ui面板搭建
前言
由于工作环境的需要,我们通常需要一些魔法代理。过去使用xui来搭建面板,但是作者很久没更新了。如今出现了很多变种版本,这里我使用的是伊朗开发的3xui。这里记录下我的搭建过程。
准备工作
- vps一台,新手请重置好主流的操作系统(CentOS / Debian / Ubuntu)
- 域名一个,并解析到你的vps。
搭建面板
安装docker,docker-compose
我是采用docker容器搭建,这样就可以不干扰其他的服务。我的系统是Debain9,所以我根据官网的Debian9安装教程安装。其他的操作系统请在我提供的链接跳转后,在左侧选择你的系统版本。
- 设置仓库
1
2
3
4
5
6
7
8
9
10
11
12
13# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL <https://download.docker.com/linux/debian/gpg> -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \\
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] <https://download.docker.com/linux/debian> \\
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \\
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update - 安装
1
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- 验证
1
2sudo docker run hello-world
# 该命令下载一个测试映像并在容器中运行它。当容器运行时,它打印一条确认消息并退出。
安装面板
执行如下的命令
1 | # 创建并进入到文件夹中 |
创建配置文件vim docker-compose.yml
,并写入下面的内容。
1 | version: "3.9" |
然后执行如下命令
1 | # 启动容器 |
启动成功之后,可以用你的vps中的ip:54321访问,就可以看到面板页面了。
域名配置(ssl开启)
- 假设你的 x-ui 端口是
54321
- 假设你的 IP 是
10.10.10.10
- 假设你的域名是
xui.example.com
,且已经做好 A 记录解析 - 假设你使用的是 Debian 10+或者 Ubuntu 18+的系统
- 假设你的邮箱是
xxxx@example.com
- 安装必要软件
1 | sudo apt update |
新建一个配置文件
1
touch /etc/nginx/conf.d/xui.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
25server {
listen 80;
listen [::]:80;
server_name xui.example.com;
location / {
proxy_redirect off;
proxy_pass <http://127.0.0.1:54321>;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
# 反代websocket
location /xray {
proxy_redirect off;
proxy_pass <http://127.0.0.1:10001>;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Y-Real-IP $realip_remote_addr;
}
}检查配置文件
1
nginx -t
申请证书,按照提示设置
1
certbot --nginx --agree-tos --no-eff-email --email xxxxx@example.com
更多细节可以参考 cerbot
刷新Nginx配置
1
nginx -s reload
配置定时任务
1
sudo certbot renew --dry-run
申请其他的域名证书
1
certbot --nginx -d xx.com -d www.xx.com
之后在面板里面配置证书位置,将证书就可以用域名:端口的形式访问。
开启BBR加速
执行下面的脚本命令
1 | wget -N --no-check-certificate "<https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh>" && chmod +x tcp.sh && ./tcp.sh |
选择安装你喜欢的内核,并开启减速管理。注意锐速内核是降级,BBR魔改是升级,所以不要混着安装这2个。
certbot常用指令
1.查看证书指令
1 | certbot certificates |
手动续期
方法1:1
certbot --nginx certonly -n -d domain
domain为你的域名
方法2:
1
certbot renew --cert-name domain --dry-run
删除证书
1
sudo certbot delete --cert-name example.com
Reality协议
目标网站最低标准:国外网站,支持 TLSv1.3 与 H2,域名非跳转用
加分项:IP 相近(更像,且延迟低),Server Hello 后的握手消息一起加密(如 dl.google.com),有 OCSP Stapling
配置加分项:禁回国流量,TCP/80、UDP/443 也转发(REALITY 对外表现即为端口转发,目标 IP 冷门或许更好)
可以使用这个网站:点击访问 ,来寻找 TLS1.3 / X25519 / H2
的指向站点。
也可以使用这个网站:点击访问 ,来查询目标网站是否支持 OCSP Stapling
(加分项而已,不支持也没有太大关系)
注意:大家代理出现问题,第一个需要检查的是目标网站是否存在问题!!!!!!