创建Xray服务器


写在前面:我爱我的祖国,我爱党,党是永远光荣正确的

由于外贸论坛上说这货是未来之光,本着猎奇的心态,安装测试下

准备工作

1、申请一个域名

2、申请证书

具体参考本站文档《创建HTTPS web服务》,在本文不再过多叙述

Xray服务安装

和相关的软件一样,我们通过一键安装脚本来安装Xray服务器

bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u <yourUserName>
配置服务器

Xray服务器支持多种配置模式,包含基础版和进阶版,现在分别将配置文件说明如下

1、基础版本

{
    "log": {
      "loglevel": "warning",
      "access": "/PathTo/access.log",
      "error": "/PathTo/error.log"
    },
    "dns": {
      "servers": [
        "https+local://1.1.1.1/dns-query",
        "itkengzhu.ga"
      ]
    },
    "routing": {
      "domainStrategy": "AsIs",
      "rules": [
        {
          "type": "field",
          "ip": [
            "geoip:private"
          ],
          "outboundTag": "block"
        },
        {
          "type": "field",
          "domain": [
            "geosite:category-ads-all"
          ],
          "outboundTag": "block"
        }
      ]
    },
    "inbounds": [
      {
        "port": 443,
        "protocol": "vless",
        "settings": {
          "clients": [
            {
              "id": "1a6f4c6a-8c19-4e26-9e80-4dbb585581b1",
              "flow": "xtls-rprx-direct",
              "level": 0,
              "email": "vpsadmin@yourdomain.com"
            }
          ],
          "decryption": "none",
          "fallbacks": [
            {
              "dest": 80
            }
          ]
        },
        "streamSettings": {
          "network": "tcp",
          "security": "xtls",
          "xtlsSettings": {
            "allowInsecure": false,
            "minVersion": "1.2",
            "alpn": ["http/1.1"],
            "certificates": [
              {
                "certificateFile": "/etc/letsencrypt/live/itkengzhu.ga/fullchain.pem",
                "keyFile": "/etc/letsencrypt/live/itkengzhu.ga/privkey.pem"
              }
            ]
          }
        }
      }
    ],
    "outbounds": [
      {
        "tag": "direct",
        "protocol": "freedom"
      },
      {
        "tag": "block",
        "protocol": "blackhole"
      }
    ]
}

2、进阶版

xray的进阶版可以开通lts+ws的分流,并且通过CDN对网站的实际地址进行隐藏。

{
  "log": {
    "loglevel": "warning", 
    "access": "/home/opc/xray_log/access.log",
    "error": "/home/opc/xray_log/error.log" 
  },
  "dns": {
    "servers": [
      "https+local://1.1.1.1/dns-query", 
      "localhost"
    ]
  },
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "ip": [
          "geoip:private" 
        ],
        "outboundTag": "block" 
      },
      {
        "type": "field",
        "domain": [
          "geosite:category-ads-all" 
        ],
        "outboundTag": "block" 
      }
    ]
  },
  "inbounds": [
    {
      "port": 443,
      "protocol": "vless",
      "settings": {
        "clients": [
          {
            "id": "1a6f4c6a-8c19-4e26-9e80-4dbb585581b1", 
            "flow": "xtls-rprx-direct",
            "level": 0,
            "email": "vpsadmin@yourdomain.com"
          }
        ],
        "decryption": "none",
        "fallbacks": [
	  {
            "path": "/wsmessage", 
            "dest": 5688,
            "xver": 1
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "xtls",
        "xtlsSettings": {
          "allowInsecure": false, 
          "minVersion": "1.2", 
          "alpn": ["http/1.1"],
          "certificates": [
            {
              "certificateFile": "/etc/letsencrypt/live/itkengzhu.ga/fullchain.pem",
              "keyFile": "/etc/letsencrypt/live/itkengzhu.ga/privkey.pem"
            }
          ]
        }
      }
    },
    {
            "port": 5688,
            "listen": "127.0.0.1",
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "1a6f4c6a-8c19-4e26-9e80-4dbb585581b1", 
                        "level": 0,
                        "email": "vpsadmin@yourdomain.com"
                    }
                ],
		"fallbacks": [
                    {
                        "dest": 80 
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "ws",
                "security": "none",
                "wsSettings": {
                    "acceptProxyProtocol": true, 
                    "path": "/wsmessage"
                }
            }
      }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom"
    },
    {
      "tag": "block",
      "protocol": "blackhole"
    }
  ]
}
启动服务器
sudo systemctl start xray
Xray客户端配置

我们使用的是v2rayN-Core,其xlts配置方式为

其ws的配置方式为:

,

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注