云服务器搭建 Clash 代理节点完整教程(基于 Xray)

4/9/2026314 words2 min read36

本文详细介绍如何在云服务器上搭建可供 Clash 使用的代理节点,基于 Xray 实现,从服务器准备、环境配置到客户端接入,提供完整步骤与优化建议,适合初学者快速上手。

云服务器搭建 Clash 代理节点完整教程(基于 Xray)

一、前言

Clash 是客户端工具,本身不提供代理服务。要使用 Clash,需要先在云服务器上搭建代理节点(如 Xray),再在 Clash 中接入。


二、基本架构

本地设备(Clash)
        ↓
云服务器(Xray)
        ↓
目标网站

三、准备服务器


  • 系统:Ubuntu 20.04 / 22.04
    配置:1核1G以上
    开放端口(如 10086 或 443)



四、安装 Xray

bash <(curl -Ls https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh)

五、配置服务

编辑配置文件:

nano /usr/local/etc/xray/config.json

示例:

{
  "inbounds": [
    {
      "port": 10086,
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "你的UUID",
            "alterId": 0
          }
        ]
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom"
    }
  ]
}

生成 UUID:

cat /proc/sys/kernel/random/uuid

六、启动与放行端口

systemctl restart xray
systemctl enable xray

开放端口:

ufw allow 10086

七、配置 Clash

config.yaml 中添加:

proxies:
  - name: my-node
    type: vmess
    server: 你的服务器IP
    port: 10086
    uuid: 你的UUID
    alterId: 0
    cipher: auto

八、可选优化


  • 使用 TLS(Reality / WebSocket)提高安全性
    绑定域名
    接入 CDN(如 Cloudflare)



九、常见问题

  • 无法连接:检查端口、UUID、服务状态

  • 速度慢:更换服务器或协议

查看日志:

journalctl -u xray -f

十、总结

核心流程:
购买服务器
安装 Xray
开放端口
配置 Clash

Comments