Xray (VLESS + WS + TLS) 服务端安装指南
Xray (VLESS + WS + TLS) 服务端安装指南
本指南记录了基于 Xray 核心的手动安装流程,包含 SSL 证书自动申请与部署。
1. 安装 Xray 核心
使用官方脚本一键安装 Xray:
bash <(curl -Ls https://github.com/XTLS/Xray-install/raw/main/install-release.sh)
# 验证版本
xray version
2. 申请 SSL 证书
为了确保传输安全(TLS),我们使用 acme.sh 申请免费的 Let's Encrypt 证书。
安装 acme.sh 及其依赖
# 安装 socat (standalone 模式必须)
apt install socat # Ubuntu/Debian
# 或 dnf install socat # CentOS/AlmaLinux
# 安装脚本
curl https://get.acme.sh | sh
source ~/.bashrc
签发证书
这里使用 standalone 模式(确保 80 端口未被占用):
# 切换 CA 为 Let's Encrypt
acme.sh --set-default-ca --server letsencrypt
# 申请证书
acme.sh --issue -d alhk.427221.xyz --standalone
安装证书到指定目录
创建配置目录并安装证书,设置自动重载 Xray:
mkdir -p /etc/xray
acme.sh --install-cert -d alhk.427221.xyz \
--key-file /etc/xray/alhk.key \
--fullchain-file /etc/xray/alhk.crt \
--reloadcmd "systemctl restart xray"
3. 配置 Xray
编辑配置文件 /etc/xray/config.json,将之前的 VLESS 配置粘贴进去。
核心配置清单 (JSON)
- 协议: VLESS
- 端口: 443
- 流控: WebSocket (WS)
- TLS: 开启,路径指向
/etc/xray/alhk.crt
4. 服务管理
配置完成后,启动并检查服务状态:
# 重新加载系统服务
systemctl daemon-reload
# 开机自启并启动
systemctl enable xray
systemctl restart xray
# 查看状态(确保是 active/running)
systemctl status xray
5. 客户端连接信息
根据你的配置,生成的标准连接信息如下:
"****************************"
注意事项
- 防火墙: 记得放行服务器的
443/tcp端口。 - 证书续期:
acme.sh会自动续期,并在续期后通过--reloadcmd自动帮你重启 Xray 使得新证书生效。 - 域名解析: 确保
alhk.427221.xyz已经解析到你当前服务器的 IP。
Xray (VLESS + WS + TLS) 服务端安装指南
https://blog.427221.xyz/archives/xray-vless-ws-tls-fu-wu-duan-an-zhuang-zhi-nan