静看光阴荏苒
不管不顾不问不说也不念

V2Ray+WebSocket+TLS+Nginx

这是v2ray一个稍微高级一点的玩法,折腾党可以试试。开始之前,你要准备一个域名解析到你的VPS。

更新系统:

yum -y update

这里为了简化步骤(偷懒)使用v2ray官方的一键安装脚本,先把v2ray装起来:

bash <(curl -L -s https://install.direct/go.sh)

设置开启启动:

systemctl enable v2ray

安装EPEL源,我这里是使用的搬瓦工的CentOS7X64,发现他这个系统模板应该是有点问题,EPEL源不知道怎么回事不能生效,解决办法是先卸载再重新装一遍,先查找:

rpm -qa | grep epel-release

然后卸载:

rpm -e epel-release-7-11.noarch

重新安装EPEL:

yum -y install epel-release

安装certbot用于签发SSL证书:

yum -y install certbot

这里就先把SSL证书申请好:

certbot certonly --standalone -d example.com

如果一切正常,你申请好的证书和私钥路径应该是类似这样子的:

/etc/letsencrypt/live/example.com/fullchain.pem
/etc/letsencrypt/live/example.com/privkey.pem

现在添加一个Nginx安装源:

vi /etc/yum.repos.d/nginx.repo

写入:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

安装Nginx:

yum -y install nginx

设置开机启动:

systemctl enable nginx

新建一个Nginx站点配置文件:

vi /etc/nginx/conf.d/v2ray.conf

写入:

server {
    listen       443 ssl;
    server_name  example.com;

    ssl_certificate    /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key    /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    error_page 497  https://$host$request_uri;

location /ray {
    proxy_pass       http://127.0.0.1:10000;
    proxy_redirect             off;
    proxy_http_version         1.1;
    proxy_set_header Upgrade   $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host      $http_host;
    }
}

然后我们备份一下v2ray的默认配置文件:

cp /etc/v2ray/config.json /etc/v2ray/config.jsonbak

清空配置文件的内容:

echo "" > /etc/v2ray/config.json

编辑配置文件:

vi /etc/v2ray/config.json

写入如下配置:

{
  "inbounds": [
    {
      "port": 10000,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "你的UUID",
            "alterId": 64
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/ray"
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

注:

上面的配置内,UUID自行使用这个网站生成一个:https://www.uuidgenerator.net

全部完成之后,把系统防火墙关了:

systemctl stop firewalld.service

同时把SELinux也关了:

vi /etc/selinux/config
SELINUX=disabled
setenforce 0

现在启动v2ray和nginx:

systemctl start v2ray
systemctl start nginx

你应该使用如下命令查看这两个软件目前是否运行正常:

systemctl status v2ray
systemctl status nginx

如果正常则可以看到类似如图回显:

至此,服务端这块我们就配置完成了。接下来是客户端的配置。

首先我们要下载两个软件:

1.https://github.com/v2ray/v2ray-core/releases
2.https://github.com/2dust/v2rayN

下载解压,把2复制到1内,接着打开这个v2rayN,点击服务器-添加VMess服务器,然后按照下图进行填写:

注:

图中的这个UUID(用户ID)要和你之前服务端配置的UUID一致(不要用这个界面上面的生成功能去生成),另外伪装域名这块我建议留空,因为我这边不知道为什么配置了这个伪装后连接非常不稳定,去掉后就正常了。

这是搬瓦工的CN2GIA,未安装BBR的油管测速,还行吧,比SSR的速度慢一些:

参考文献:

https://www.v2ray.com/chapter_02/transport/websocket.html

赞(3)
未经允许不得转载:荒岛 » V2Ray+WebSocket+TLS+Nginx
分享到: 更多 (0)

评论 17

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    位置我蹲第一位吧,这种之前搭过了 :razz:

    1235年前 (2018-12-29) Google Chrome 71.0.3578.98 Google Chrome 71.0.3578.98 Windows 7 x64 Edition Windows 7 x64 Edition回复
  2. #2

    不知道是不是服务器问题,同时搭建酸酸乳和这个,慢的很

    瞎折腾5年前 (2018-12-29) Google Chrome 68.0.3440.91 Google Chrome 68.0.3440.91 Android 6.0.1 Android 6.0.1回复
    • 这个是要慢一点,但不至于慢的很。。

      LALA5年前 (2018-12-29) Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 10 x64 Edition Windows 10 x64 Edition回复
  3. #3

    这个一键真香 https://github.com/wulabing/V2Ray_ws-tls_bash_onekey

    demo5年前 (2018-12-29) Google Chrome 71.0.3578.80 Google Chrome 71.0.3578.80 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 已收藏,3Q!

      LALA5年前 (2018-12-29) Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 10 x64 Edition Windows 10 x64 Edition回复
  4. #4

    有个疑问,防火墙之后就一直保持关闭了嘛。。虽然我也喜欢一直关着(其实是懒得折腾),但不会有什么安全隐患吧。。(除了总有人试图登录ssh这种)

    橘子5年前 (2019-06-10) Google Chrome 71.0.3578.97 Google Chrome 71.0.3578.97 Windows 8.1 x64 Edition Windows 8.1 x64 Edition回复
    • 一般也就是SSH爆破这种,给SSH换个端口就行了,Linux还是很安全的,真要出了什么大漏洞,防火墙也没啥作用。。安全永远都是相对的,没有绝对的安全。。

      LALA5年前 (2019-06-10) Google Chrome 74.0.3729.169 Google Chrome 74.0.3729.169 Windows 10 x64 Edition Windows 10 x64 Edition回复
  5. #5

    聊天室怕不是又booooom了 :wink:

    橘子5年前 (2019-06-12) Google Chrome 72.0.3626.88 Google Chrome 72.0.3626.88 Windows 8.1 x64 Edition Windows 8.1 x64 Edition回复
    • = =好像是的,我看下。。

      LALA5年前 (2019-06-13) Google Chrome 74.0.3729.169 Google Chrome 74.0.3729.169 Windows 10 x64 Edition Windows 10 x64 Edition回复
  6. #6

    强烈建议支持tls1.3!历史的车轮不能倒流! :wink:
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-256-GCM-SHA384:TLS13-AES-128-GCM-SHA256:EECDH+CHACHA20:EECDH+AESGCM:EECDH+AES;

    橘子5年前 (2019-07-11) Google Chrome 72.0.3626.82 Google Chrome 72.0.3626.82 Windows 10 Windows 10回复
    • 另外防火墙不仅要关还要毙了 :idea:

      橘子5年前 (2019-08-06) Google Chrome 76.0.3809.90 Google Chrome 76.0.3809.90 Windows 10 Windows 10回复
      • 感受到墙的痛苦了? :razz:

        LALA5年前 (2019-08-06) Google Chrome 74.0.3729.169 Google Chrome 74.0.3729.169 Windows 10 x64 Edition Windows 10 x64 Edition回复
  7. #7

    马克https://lala.im/6187.html#comments

    橘子5年前 (2019-08-07) Google Chrome 75.0.3770.87 Google Chrome 75.0.3770.87 Windows 8 x64 Edition Windows 8 x64 Edition回复
  8. #8

    阅读量1w :wink:

    橘子4年前 (2020-03-01) Google Chrome 77.0.3833.89 Google Chrome 77.0.3833.89 Windows 8 x64 Edition Windows 8 x64 Edition回复
  9. #9

    v2ray官方脚本搬家了
    https://github.com/v2fly/fhs-install-v2ray

    橘子4年前 (2020-08-17) Google Chrome 84.0.4147.143 Google Chrome 84.0.4147.143 Windows 7 x64 Edition Windows 7 x64 Edition回复
  10. #10

    更新一下v2fly官方安装:
    bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
    配置文件通常位于 /etc/v2ray/ 或 /usr/local/etc/v2ray/ 目录下。

    橘子3年前 (2021-09-23) Google Chrome 84.0.4147.121 Google Chrome 84.0.4147.121 Windows 10 x64 Edition Windows 10 x64 Edition回复

分享创造快乐

广告合作资源投稿