学习之路—科学

VPS 节点搭建教程(x-ui 面板 + VMess + WebSocket)

1. 重置服务器时间

确保服务器时间与实际区域时间一致。以下以纽约时间为例:


bash

复制代码

sudo timedatectl set-timezone America/New_York sudo systemctl restart systemd-timesyncd # 或者 sudo ntpdate -s time.nist.gov

2. 提升权限并安装必要组件

进入 root 用户,更新系统并安装必要组件:


bash

复制代码

sudo -i # 输入密码,可能不显示,输入后回车 # Debian/Ubuntu 命令 apt update -y apt install -y curl socat # CentOS 命令 yum update -y yum install -y curl socat

3. 配置防火墙

开放必要的端口:


bash

复制代码

# Debian/Ubuntu 防火墙管理 apt install firewalld firewall-cmd --add-port=54321/tcp --permanent firewall-cmd --add-port=80/tcp --permanent firewall-cmd --add-port=443/tcp --permanent firewall-cmd --reload # CentOS 防火墙管理 yum install firewalld firewall-cmd --add-port=54321/tcp --permanent firewall-cmd --add-port=80/tcp --permanent firewall-cmd --add-port=443/tcp --permanent firewall-cmd --reload

4. 申请 SSL 证书(使用 Acme 脚本)

确保域名已解析到 VPS 的 IP 地址,然后申请 SSL 证书:


bash

复制代码

curl https://get.acme.sh | sh # 注册账号并申请证书,替换为你的邮箱和域名 ~/.acme.sh/acme.sh --register-account -m your_email@example.com ~/.acme.sh/acme.sh --issue -d yourdomain.com --standalone # 安装证书到指定文件夹,替换为你的域名 ~/.acme.sh/acme.sh --installcert -d yourdomain.com --key-file /root/private.key --fullchain-file /root/cert.crt

5. 安装与升级 x-ui 面板

使用一键脚本安装或升级 x-ui 面板:


bash

复制代码

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

6. 启用 BBR 加速

BBR 可以显著提高网络传输性能:


bash

复制代码

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl -p sysctl net.ipv4.tcp_available_congestion_control

7. 配置 Nginx 反向代理(用于 WebSocket + TLS 伪装)


bash

复制代码

apt install nginx -y # 编辑 Nginx 配置文件 nano /etc/nginx/sites-available/default # Nginx 配置示例 server { listen 80; server_name yourdomain.com; location / { return 301 https://$host$request_uri; } } server { listen 443 ssl; server_name yourdomain.com; ssl_certificate /root/cert.crt; ssl_certificate_key /root/private.key; location / { proxy_pass http://127.0.0.1:54321; # 替换为你的 x-ui 监听端口 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }

保存并退出编辑器后,测试 Nginx 配置文件:


bash

复制代码

nginx -t

如果配置正确,重启 Nginx:


bash

复制代码

systemctl restart nginx

8. x-ui 面板配置

访问 x-ui 面板,默认端口为 54321


arduino

复制代码

http://your_server_ip:54321

登录后,默认用户名和密码均为 admin(登录后建议修改密码)。

配置 VMess + WebSocket 节点:

协议:VMess传输方式:WebSocket伪装路径:设置为 /(与 Nginx 配置匹配)使用 TLS,并选择刚刚申请的 SSL 证书。

优化配置

调整 mux 设置:在 x-ui 面板中,设置合理的 mux(多路复用)参数,通常值在 1 到 10 之间。根据流量需求进行调整,以提高连接效率和并发处理能力。配置 alterId:在 VMess 节点配置中,设置适当的 alterId,通常推荐在 4 到 16 之间。较高的 alterId 数量可以提高安全性和混淆性,但过高可能导致性能下降。优化传输协议:确保使用 WebSocket 传输方式,并配置合适的伪装路径(例如 /your_path),与 Nginx 的配置保持一致,以提升稳定性和隐匿性。开启 TLS 加密:在节点配置中启用 TLS,并使用刚申请的 SSL 证书,确保数据传输加密,以增加安全性。流量分流:设置合理的流量分流策略,避免特定流量过多导致的节点负载过高。可以在 x-ui 面板中配置规则,优化流量分配。

定期更新和维护

定期检查 x-ui 的更新,确保使用最新版本,以修复可能存在的漏洞和提升性能。更新命令:
bash

复制代码

x-ui update

9. 客户端配置

在客户端(如 V2RayN、V2RayNG)中导入节点信息,确保协议、加密方式、传输路径与服务器配置匹配。客户端配置示例:

服务器地址yourdomain.com端口443协议:VMess加密方式:默认传输方式:WebSocket伪装路径/TLS:开启

10. 监控与维护

定期更新 x-ui 和系统:


bash

复制代码

x-ui update apt update && apt upgrade -y

监控服务器资源和流量,及时调整配置。

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...