Xray协议终极应用,全协议(Trojan,VLESS,Vmess)同时连接,Xray强大的回落功能(第三篇)

文章导读目录

 

前言

很多小伙伴在咨询 Xray 和 Trojan 共存等一些方面的教程,其实吧,Xray 它是支持 Trojan 协议的。

我们前几期视频提到了 Xray 强大的回落功能,其实 Xray 的分流功能也是很强大,大家看下面一些我们经常搭建的协议

  • VLESS over TCP with XTLS(数倍性能,首选方式)
  • VLESS over TCP with TLS
  • VLESS over WS with TLS
  • VMess over TCP with TLS
  • VMess over WS with TLS
  • Trojan over TCP with TLS

在 Xray 中,我们是支持上面的 所有协议 同时 连接我们的服务器的。

不相信?那我们继续!

准备工作

1、VPS 一台,重置好主流的操作系统。

2、域名一个,并解析到 VPS,若是需要开启 CDN,请自行托管域名到 CloudFlare。

(若是域名申请、解析以及托管到 CloudFlare)

3、自行安装 BBR 加速之类的软件

开始搭建

更新系统

CentOS 需要安装开源发行软件包版本库,命令如下

  1. yum install epel-release -y
  2. yum update -y

Debian更新系统较为简单

  1. apt update -y

安装 Curl Nginx Tar

  1. yum install curl tar nginx -y #CentOS命令
  2. apt install curl tar nginx -y #Debian命令

CentOS 为了避免FireWalld,请务必直接执行下面代码,Debian跳过

  1. firewall-cmd --zone=public --add-port=80/tcp --permanent
  2. firewall-cmd --zone=public --add-port=443/tcp --permanent
  3. firewall-cmd --reload

启动 Nginx服务

(PS:在执行下面命令之前,一定记得重启一下 VPS,以免上述的更新命令没有完成导致 Nginx 无法启动,有的搬瓦工机器需要人工重启——因为我的就是如此 )

  1. systemctl start nginx

现在可以在浏览器中输入你的域名,看看是否可以访问到 Nginx 的欢迎页面

安装官方Xray服务

以下一键安装程序来源于官方

  1. bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u root

UUID 随机生成代码

  1. cat /proc/sys/kernel/random/uuid # 粘贴到VPS运行即可生成 UUID

安装完毕以后,在VPS目录 /usr/local/etc/xray 找到 config,json 文件,贴入下面的配置文件

更多范例的 Xray 配置文件,请点击 官方的 Xray 配置模板库

  1. {
  2. "log": {
  3. "loglevel": "warning"
  4. },
  5. "inbounds": [
  6. {
  7. "port": 443,
  8. "protocol": "vless",
  9. "settings": {
  10. "clients": [
  11. {
  12. "id": "c4616432-97cd-4514-8979-f3a426fccdfd", // 填写你的 UUID
  13. "flow": "xtls-rprx-direct",
  14. "level": 0,
  15. "email": "[email protected]"
  16. }
  17. ],
  18. "decryption": "none",
  19. "fallbacks": [
  20. {
  21. "dest": 1310, // 默认回落到 Xray 的 Trojan 协议
  22. "xver": 1
  23. },
  24. {
  25. "path": "/websocket", // 必须换成自定义的 PATH
  26. "dest": 1234,
  27. "xver": 1
  28. },
  29. {
  30. "path": "/vmesstcp", // 必须换成自定义的 PATH
  31. "dest": 2345,
  32. "xver": 1
  33. },
  34. {
  35. "path": "/vmessws", // 必须换成自定义的 PATH
  36. "dest": 3456,
  37. "xver": 1
  38. }
  39. ]
  40. },
  41. "streamSettings": {
  42. "network": "tcp",
  43. "security": "xtls",
  44. "xtlsSettings": {
  45. "alpn": [
  46. "http/1.1"
  47. ],
  48. "certificates": [
  49. {
  50. "certificateFile": "/usr/local/etc/xray/cert/cert.crt", // 换成你的证书,绝对路径
  51. "keyFile": "/usr/local/etc/xray/cert/private.key" // 换成你的私钥,绝对路径
  52. }
  53. ]
  54. }
  55. }
  56. },
  57. {
  58. "port": 1310,
  59. "listen": "127.0.0.1",
  60. "protocol": "trojan",
  61. "settings": {
  62. "clients": [
  63. {
  64. "password": "00000000", // 填写你的密码
  65. "level": 0,
  66. "email": "[email protected]"
  67. }
  68. ],
  69. "fallbacks": [
  70. {
  71. "dest": 80 // 或者回落到其它也防探测的代理
  72. }
  73. ]
  74. },
  75. "streamSettings": {
  76. "network": "tcp",
  77. "security": "none",
  78. "tcpSettings": {
  79. "acceptProxyProtocol": true
  80. }
  81. }
  82. },
  83. {
  84. "port": 1234,
  85. "listen": "127.0.0.1",
  86. "protocol": "vless",
  87. "settings": {
  88. "clients": [
  89. {
  90. "id": "c4616432-97cd-4514-8979-f3a426fccdfd", // 填写你的 UUID
  91. "level": 0,
  92. "email": "[email protected]"
  93. }
  94. ],
  95. "decryption": "none"
  96. },
  97. "streamSettings": {
  98. "network": "ws",
  99. "security": "none",
  100. "wsSettings": {
  101. "acceptProxyProtocol": true, // 提醒:若你用 Nginx/Caddy 等反代 WS,需要删掉这行
  102. "path": "/websocket" // 必须换成自定义的 PATH,需要和分流的一致
  103. }
  104. }
  105. },
  106. {
  107. "port": 2345,
  108. "listen": "127.0.0.1",
  109. "protocol": "vmess",
  110. "settings": {
  111. "clients": [
  112. {
  113. "id": "c4616432-97cd-4514-8979-f3a426fccdfd", // 填写你的 UUID
  114. "level": 0,
  115. "email": "[email protected]"
  116. }
  117. ]
  118. },
  119. "streamSettings": {
  120. "network": "tcp",
  121. "security": "none",
  122. "tcpSettings": {
  123. "acceptProxyProtocol": true,
  124. "header": {
  125. "type": "http",
  126. "request": {
  127. "path": [
  128. "/vmesstcp" // 必须换成自定义的 PATH,需要和分流的一致
  129. ]
  130. }
  131. }
  132. }
  133. }
  134. },
  135. {
  136. "port": 3456,
  137. "listen": "127.0.0.1",
  138. "protocol": "vmess",
  139. "settings": {
  140. "clients": [
  141. {
  142. "id": "c4616432-97cd-4514-8979-f3a426fccdfd", // 填写你的 UUID
  143. "level": 0,
  144. "email": "[email protected]"
  145. }
  146. ]
  147. },
  148. "streamSettings": {
  149. "network": "ws",
  150. "security": "none",
  151. "wsSettings": {
  152. "acceptProxyProtocol": true, // 提醒:若你用 Nginx/Caddy 等反代 WS,需要删掉这行
  153. "path": "/vmessws" // 必须换成自定义的 PATH,需要和分流的一致
  154. }
  155. }
  156. }
  157. ],
  158. "outbounds": [
  159. {
  160. "protocol": "freedom"
  161. }
  162. ]
  163. }

为域名申请证书

(记得申请完毕以后,证书文件命名为 cert.crt ,密钥文件命名为 private.key,存放到 /usr/local/etc/xray/cert/ 文件夹之下,若是没有该文件夹,请自行新建!)

以下六行脚本请逐行复制粘贴到 VPS 运行

PS:务必修改下面的域名和邮箱为你自己的域名、邮箱

  1. curl https://get.acme.sh | sh
  2. ~/.acme.sh/acme.sh --register-account -m xxxx@xxxx.com
  3. ~/.acme.sh/acme.sh --issue -d 1.bozai.us --webroot /usr/share/nginx/html/
  4. mkdir /usr/local/etc/xray/cert
  5. ~/.acme.sh/acme.sh --installcert -d 1.bozai.us --key-file /usr/local/etc/xray/cert/private.key --fullchain-file /usr/local/etc/xray/cert/cert.crt
  6. ~/.acme.sh/acme.sh --upgrade --auto-upgrade
  7. chmod -R 755 /usr/local/etc/xray/cert

证书默认的更新周期为60天(自动),若是出问题,请再次自行框内的代码即可

设置 Nginx 开机启动

并重新启动 Nginx

  1. systemctl enable nginx
  2. systemctl restart nginx

检验Xray配置文件

  1. systemctl restart xray #重启xray服务
  2. systemctl status xray #查看xray运行状态

下载伪装网站及部署

默认的网站主程序文件夹在 /usr/share/nginx/html/ ,大家可以自行的替换里面的任何东西(整站程序)

  1. rm -rf /usr/share/nginx/html/*
  2. cd /usr/share/nginx/html/
  3. wget https://github.com/V2RaySSR/Trojan/raw/master/web.zip
  4. unzip web.zip
  5. systemctl restart nginx

到此,就部署完毕了。相对来说也是很简单。现在你就可以打开 QV2ray 和 V2ray 连接你的节点了

具体的填入参数可以参考下图:

后记

大家可以随心所欲的去互联网看小姐姐了。