V2ray多合一脚本,支持VMESS+websocket+TLS+Nginx、VLESS+TCP+XTLS、VLESS+TCP+TLS等组合

2020.12.05更新:最新版V2ray-core已经移除了XTLS,如果你要使用XTLS技术,推荐用 Xray一键脚本

今天抽空把支持V2ray最新VLESS协议一键脚本弄完了。本次的V2ray一键脚本功能强大,支持常规VMESS协议、VMESS+websocket+TLS+Nginx、VLESS+TCP+XTLS、VLESS+TCP+TLS等多种组合,支持CentOS 7/8、Ubuntu 16.04以上、Debian 8以上系统,以及相关衍生系统。

注意:目前CentOS7系统已经到生命周期,不建议使用该系统,可能会导致脚本运行失败!建议使用Debian或者Ubuntu系统。

V2ray VLESS+TCP+XTLS一键脚本

V2ray一键脚本使用步骤如下:

1. 准备一个境外服务器,想服务器速度快请参考 搬瓦工VPS购买教程 或从  CN2 GIA VPS商家推荐 选购,想ip被封后免费换请参考:购买vultr服务器超详细图文教程

如果用VMESS+WS+TLS或者VLESS系列协议,则还需一个域名。对域名没有要求,国内/国外注册的都可以,不需要备案,不会影响使用,也不会带来安全/隐私上的问题。购买域名可参考:Namesilo购买域名详细教程

值得一提的是本V2ray一键脚本支持ipv6 only服务器,但是不建议用只有ipv6的VPS用来科学上网。

2. 如果vps运营商开启了防火墙(阿里云、Ucloud、腾讯云、AWS、GCP等商家默认有,搬瓦工/hostdare/vultr等商家默认关闭),请先登录vps管理后台放行80和443端口,否则可能会导致获取证书失败。此外,本脚本支持上传自定义证书,可跳过申请证书这一步,也可用在NAT VPS上。

3. ssh连接到服务器。Windows系统请参考 Bitvise连接Linux服务器教程,mac用户请参考 Mac电脑连接Linux教程

4. 复制(或手动输入)下面命令到终端:

bash <(curl -sL https://raw.githubusercontent.com/daveleung/hijkpw-scripts-mod/main/xray_mod1.sh)

按回车键,将出现如下操作菜单。如果菜单没出现,CentOS系统请输入 yum install -y curl,Ubuntu/Debian系统请输入 apt install -y curl,然后再次运行上面的命令:

V2ray一键脚本安装菜单

V2ray一键脚本安装菜单

目前V2ray一键脚本支持以下功能:

  • VMESS,即最普通的V2ray服务器,没有伪装,也不是VLESS
  • VMESS+KCP,传输协议使用mKCP,VPS线路不好时可能有奇效
  • VMESS+TCP+TLS,带伪装的V2ray,不能过CDN中转
  • VMESS+WS+TLS,即最通用的V2ray伪装方式,能过CDN中转,推荐使用
  • VLESS+KCP,传输协议使用mKCP
  • VLESS+TCP+TLS,通用的VLESS版本,不能过CDN中转,但比VMESS+TCP+TLS方式性能更好
  • VLESS+WS+TLS,基于websocket的V2ray伪装VLESS版本,能过CDN中转,有过CDN情况下推荐使用
  • VLESS+TCP+XTLS,目前最强悍的VLESS+XTLS组合,强力推荐使用(但是支持的客户端少一些)
  • trojan,轻量级的伪装协议
  • trojan+XTLS,trojan加强版,使用XTLS技术提升性能

注意:目前一些客户端不支持VLESS协议,或者不支持XTLS,请按照自己的情况选择组合

5. 按照自己的需求选择一个方式。例如6,然后回车。接着脚本会让你输入一些信息,也可以直接按回车使用默认值。需要注意的是,对于要输入伪装域名的情况,如果服务器上有网站在运行,请联系运维再执行脚本,否则可能导致原来网站无法访问!

VLESS+TCP+XTLS一键脚本输入信息

VLESS+TCP+XTLS一键脚本输入信息

6. 脚本接下来会自动运行,一切顺利的话结束后会输出配置信息:

VLESS+TCP+XTLS一键脚本输出信息

VLESS+TCP+XTLS一键脚本输出信息

注意,脚本不适用最新版,原因是脚本在安装v2ray过程中,第822行默认从(https://github.com/v2fly/v2ray-core/releases/)抓取最新版本。解压后cp到对应位置,目前的最新版本为v5.1.0。该版本解压后,没有v2ctl文件,copy失败后,导致脚本意外终止,请作者予以修正。

脚本未修正前的临时解决方法:
wget https://raw.githubusercontent.com/daveleung/hijkpw-scripts-mod/main/v2ray_mod1.sh
chmod a+x v2ray_mod1.sh
vi v2ray_mod1.sh
(将822行中的${NEW_VER}修改为v4.45.2)
./v2ray_mod1.sh

到此服务端配置完毕,服务器可能会自动重启(没提示重启则不需要),windows终端出现“disconnected”,mac出现“closed by remote host”说明服务器成功重启了。

对于VLESS协议、VMESS+WS+TLS的组合,网页上输入伪装域名,能正常打开伪装站,说明服务端已经正确配置好。如果运行过程中出现问题,请在本页面下方查找解决方法或留言。

V2ray一键脚本注意事项

服务端配置好后,如果想使用CloudFlare等CDN中转(必须是WS版才可以),请参考:使用cloudflare中转流量,拯救被墙ip

本脚本默认使用的加速技术是BBR,换成魔改BBR/BBR Plus/锐速清参考:安装魔改BBR/BBR Plus/锐速(Lotserver)

如果伪装站类型没有你满意的,比如你想搭建WordPress博客,请参考:V2ray伪装建站教程

对于使用TLS的方式,脚本默认会申请域名证书,证书存放在和V2ray配置文件同一个文件夹内(即/etc/v2ray目录下)。证书会自动更新,如果客户端突然无法使用,请打开伪装网站查看是否能正常打开。如果证书已过期,请再次运行上面的脚本重新配置。

最后,刚搭建好V2ray后不要猛上流量,否则会导致被限速、端口被墙,严重可能导致ip被墙。

接下来是配置客户端,下载客户端和配置教程请参考:

祝大家使用愉快。如有问题请在页面下方留言。

参考

  1. V2ray一键脚本
  2. V2ray带伪装一键脚本
  3. V2ray的VLESS协议介绍和使用教程
  4. VLESS协议的fallback参数详解

《V2ray多合一脚本,支持VMESS+websocket+TLS+Nginx、VLESS+TCP+XTLS、VLESS+TCP+TLS等组合》上有783条评论

  1. cp: cannot stat ‘/tmp/v2ray/v2ctl’: No such file or directory
    chmod: cannot access ‘/usr/bin/v2ray/v2ctl’: No such file or directory
    请问v2一键安装时提示这个是什么意思

      1. 非常感谢楼主,大数据让我们相识。按照教程一步步来已经成功出墙,手机也在使用。万分感谢。

  2. cp: cannot stat ‘/tmp/v2ray/v2ctl’: No such file or directory
    chmod: cannot access ‘/usr/bin/v2ray/v2ctl’: No such file or directory
    V2ray安装失败
    [root@racknerd-f56990 ~]#

    这是什么情况?

  3. 在尝试使用vision流控时发生如下错误
    Failed to start: main: failed to load config files:[/usr/local/etc/xray/config.json] > infra/conf: VLESS clients: “flow” doesn’t support “xtls-rprx-vision” in this version

      1. 楼主,我昨天还可以用,怎么今天节点就连接不上了。这是什么问题啊

          1. 是在输入脚本后,端口443哪里改成其他端口么。

        1. [Tue 13 Jun 2023 01:59:31 AM UTC] ui.xyzs.eu.org:Verify error:194.146.26.238: Fetching http://ui.xyzs.eu.org/.well-known/acme-challenge/VIM7EEYDu2KbM6GZYof_mrEref7ztKPG8uRWpgfCk5M: Connection refused
          [Tue 13 Jun 2023 01:59:31 AM UTC] Please add ‘–debug’ or ‘–log’ to check more details.
          [Tue 13 Jun 2023 01:59:31 AM UTC] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh
          [Tue 13 Jun 2023 01:59:31 AM UTC] Run post hook:’systemctl restart nginx’
          获取证书失败,请复制上面的红色文字到 https://www.hicairo.com 反馈

  4. 您好,我之前一直用的V2rayN是4.几的版本,今天升到6.21,变化很大,又让我从头设置了一遍,但是现在一直用不了,并且显示当前服务器的真连接延迟:-1ms,请问怎么解决

    1. 问题解决了,跟之前的配置仔细对了一下,发现新加的3个选项什么都不填就行了

  5. 最近突然上不了网了,请问这个是什么原因导致的?ip地址也能ping通。现在我使用VLESS+TCP+TLS。
    客户端:
    2023/04/17 23:29:14 [Warning] [2331344415] app/proxyman/outbound: failed to process outbound traffic > proxy/vless/outbound: failed to find an available destination > common/retry: [dial tcp 38.59.242.224:443: i/o timeout dial tcp 38.59.242.224:443: operation was canceled] > common/retry: all retry attempts failed
    服务器端:
    Apr 17 15:27:34 vm228978.akkocloud.com v2ray[3951]: 2023/04/17 15:27:34 [Warning] [3066522730] app/proxyman/inbound: connection ends > proxy/vless/inbound: failed to find the default “alpn” config

        1. 您好!
          请问我这是什么问题呢,之前可以用的,今天突然不行了

          2023/06/21 15:49:40 tcp:127.0.0.1:57662 accepted tcp:optimizationguide-pa.googleapis.com:443
          2023/06/21 15:49:42 [Warning] failed to handler mux client connection > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [v2ray.com/core/transport/internet/websocket: failed to dial WebSocket > v2ray.com/core/transport/internet/websocket: failed to dial to (wss://233.ttcc.ga/): > remote error: tls: handshake failure v2ray.com/core/transport/internet/websocket: failed to dial WebSocket > v2ray.com/core/transport/internet/websocket: failed to dial to (wss://233.ttcc.ga/): > dial tcp: lookup 233.ttcc.ga: no such host v2ray.com/core/transport/internet/websocket: failed to dial WebSocket > v2ray.com/core/transport/internet/websocket: failed to dial to (wss://233.ttcc.ga/): > remote error: tls: handshake failure] > v2ray.com/core/common/retry: all retry attempts failed

      1. 请问您知道查看服务器密码的时候:
        Failed to reset root password (739102)
        Additional information: 992800003 Failed to reset root password: 722999 QEMU-KVM Agent is not running inside VE
        是什么原因吗

  6. 在cloudflare里更改DNS需要多久生效呢,去部署的时候,一直提示域名未解析到当前服务器

  7. 配置成功,PING+TCPING 都正常,真连接延迟-1
    by the remote host.] > common/retry: all retry attempts failed

  8. 安装nginx…
    Warning: ALREADY_ENABLED: http
    success
    Warning: ALREADY_ENABLED: https
    success
    success
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: mirrors.advancedhosters.com
    * centos-sclo-rh: forksystems.mm.fcix.net
    * epel: d2lzkl7pfhq30w.cloudfront.net
    * extras: mirrors.advancedhosters.com
    * updates: mirrors.advancedhosters.com
    Package socat-1.7.3.2-2.el7.x86_64 already installed and latest version
    Package 1:openssl-1.0.2k-26.el7_9.x86_64 already installed and latest version
    Nothing to do
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: mirrors.advancedhosters.com
    * centos-sclo-rh: forksystems.mm.fcix.net
    * epel: d2lzkl7pfhq30w.cloudfront.net
    * extras: mirrors.advancedhosters.com
    * updates: mirrors.advancedhosters.com
    Package cronie-1.4.11-25.el7_9.x86_64 already installed and latest version

  9. 楼主你好,我用脚本安装后显示:
    v2ray启动失败,请检查日志或查看端口是否被占用!
    V2ray运行状态:已安装 未运行
    但是可以正常打开伪装站,这是安装成功了吗?

  10. nginx 未运行
    安装nginx…
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: linux.mirrors.es.net
    * elrepo-kernel: repos.lax-noc.com
    * epel: irltoolkit.mm.fcix.net
    * extras: repos.lax.layerhost.com
    * updates: repos.lax.layerhost.com
    Package epel-release-7-14.noarch already installed and latest version
    Nothing to do
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: linux.mirrors.es.net
    * elrepo-kernel: repos.lax-noc.com
    * epel: irltoolkit.mm.fcix.net
    * extras: repos.lax.layerhost.com
    * updates: repos.lax.layerhost.com
    Package 1:nginx-1.20.1-10.el7.x86_64 already installed and latest version
    Nothing to do
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: linux.mirrors.es.net
    * elrepo-kernel: repos.lax-noc.com
    * epel: irltoolkit.mm.fcix.net
    * extras: repos.lax.layerhost.com
    * updates: repos.lax.layerhost.com
    Package socat-1.7.3.2-2.el7.x86_64 already installed and latest version
    Package 1:openssl-1.0.2k-26.el7_9.x86_64 already installed and latest version
    Nothing to do
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: linux.mirrors.es.net
    * elrepo-kernel: repos.lax-noc.com
    * epel: irltoolkit.mm.fcix.net
    * extras: repos.lax.layerhost.com
    * updates: repos.lax.layerhost.com
    Package cronie-1.4.11-25.el7_9.x86_64 already installed and latest version
    Nothing to do
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 216k 100 216k 0 0 790k 0 –:–:– –:–:– –:–:– 791k
    [Mon Jun 5 02:51:36 EDT 2023] Installing from online archive.
    [Mon Jun 5 02:51:36 EDT 2023] Downloading https://github.com/acmesh-official/acme.sh/archive/master.tar.gz
    [Mon Jun 5 02:51:37 EDT 2023] Extracting master.tar.gz
    [Mon Jun 5 02:51:37 EDT 2023] Installing to /root/.acme.sh
    [Mon Jun 5 02:51:37 EDT 2023] Installed to /root/.acme.sh/acme.sh
    [Mon Jun 5 02:51:37 EDT 2023] Installing alias to ‘/root/.bashrc’
    [Mon Jun 5 02:51:37 EDT 2023] OK, Close and reopen your terminal to start using acme.sh
    [Mon Jun 5 02:51:37 EDT 2023] Installing alias to ‘/root/.cshrc’
    [Mon Jun 5 02:51:37 EDT 2023] Installing alias to ‘/root/.tcshrc’
    [Mon Jun 5 02:51:37 EDT 2023] Installing cron job
    21 0 * * * “/root/.acme.sh”/acme.sh –cron –home “/root/.acme.sh” > /dev/null
    [Mon Jun 5 02:51:37 EDT 2023] Good, bash is found, so change the shebang to use bash as preferred.
    [Mon Jun 5 02:51:38 EDT 2023] OK
    [Mon Jun 5 02:51:38 EDT 2023] Install success!
    [Mon Jun 5 02:51:39 EDT 2023] Already uptodate!
    [Mon Jun 5 02:51:39 EDT 2023] Upgrade success!
    [Mon Jun 5 02:51:39 EDT 2023] Changed default CA to: https://acme-v02.api.letsencrypt.org/directory
    [Mon Jun 5 02:51:39 EDT 2023] Domains not changed.
    [Mon Jun 5 02:51:39 EDT 2023] Skip, Next renewal time is: 2023-08-03T06:48:39Z
    [Mon Jun 5 02:51:39 EDT 2023] Add ‘–force’ to force to renew.
    [Mon Jun 5 02:51:39 EDT 2023] Installing key to: /etc/v2ray/xqh.emdchaox.com.key
    [Mon Jun 5 02:51:39 EDT 2023] Installing full chain to: /etc/v2ray/xqh.emdchaox.com.pem
    [Mon Jun 5 02:51:39 EDT 2023] Run reload cmd: service nginx force-reload
    Redirecting to /bin/systemctl force-reload nginx.service
    Job for nginx.service invalid.
    [Mon Jun 5 02:51:40 EDT 2023] Reload error for :

  11. 请问我用作者发的脚本安装后:
    当前状态:已安装 V2ray正在运行, Nginx正在运行
    然后在V2rayN从URL导入vmess链接,但还是打不开www.google.com,请问这是为什么呢

  12. 你好,大佬。前天照你的贴子,用多合一脚本(带伪装)配置的服务端和客户端。当天搞定了,能上外网,手机端也OK。昨天晚上也可以浏览外版linkedin。
    今天早上通过Whatsapp 发信息发现发不出去了。
    伪装网站无法打开,ping IP 没问题,ping 端口 显示无法连接。
    手机端测试结果:
    失败:net/http: TLS handshake timeout.
    这个是什么原因呢?具体怎么解决?

    感谢 大佬

      1. 谢谢。我重新配置了,换了新端口,搞定了。
        我是技术小白,是重装、重新配置。有没有其他快捷换端口的方法。比如,输入命令,然后改端口,直接保存、重启生效?

          1. 大佬,有个疑问,这个新配置的端口用两天又不行了。
            使用比较简单:主要是 Whatapp给客户发点图片,linkedin上 刷刷动态。流量不大。
            配置的是 Vless+WS+TLS。
            像这样2天就被墙,有没有办法多能防止被墙呢

发表回复

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