Technology Sharing

  • 首页
  • 资料分享
  • 在线工具
    • 随机密码生成器
  • 介绍
  • RSS
  • privacy
  • 云产品推广
    • 腾讯云
    • 阿里云
Share IT knowledge
  1. 首页
  2. linux
  3. 正文

Linux 部署v2ray

2023年6月23日 416点热度 1人点赞 0条评论

架构:v2ray+WebSocket+TLS+Nginx

其实就是将流量全部伪装成https流量,由于线路上有海量的https流量,增加墙的处理难度,很大程度会被放行,但难免会被限速.

操作系统:

  • 对于CentOS,安装最新的CentOS 7或CentOS 8版本。
  • 对于Ubuntu,安装最新的Ubuntu 18.04或Ubuntu 20.04版本。

安装必要的依赖项:

centos

sudo yum install curl vim wget

ubuntu

sudo apt update
sudo apt install curl vim wget

安装v2ray

下载安装脚本

cd /usr/local/src
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh

安裝v2ray

bash install-release.sh

安裝最新发行的 geoip.dat 和 geosite.dat

bash install-dat-release.sh

修改v2ray配置文件

vim /usr/local/etc/v2ray/config.json
{
"log": {
    "loglevel": "debug",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },
"dns":{
"servers":["8.8.8.8","8.8.4.4","localhost"],
"clientIp":"服务器IP"
},

  "inbounds": [
    {
      "port": 10000,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
	  {"id": "513a4540-24ce-4ae2-a59c-bfb0616dac39","alterId": 64},
	  {"id": "d59fd1a9-7ba3-4b73-91e8-e0770a00de5d","alterId": 64}
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/ray"
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}
  • clientIp: 当前linux服务器ip地址
  • port:随机指定没有被使用的端口,跟后面nginx配置保持一致
  • id: 用uuid命令随机生成
  • network: ws
  • path: 随机指定,跟后面nginx配置保持一致

重启v2ray并设置开机自启

systemctl restart v2ray.service  &&  systemctl enable v2ray.service

部署nginx

centos安装nginx参考:https://tech.sharespace.top/centos7-yum-nginx/
ubuntu安装nginx参考:https://tech.sharespace.top/ubuntu-apt-nginx/

修改nginx配置

vim /etc/nginx/conf.d/v2ray.conf
server {
        listen 443 ssl http2;
        server_name vpn.sharespace.top;
        ssl_certificate /etc/letsencrypt/live/vpn.sharespace.top/fullchain.pem; 
        ssl_certificate_key /etc/letsencrypt/live/vpn.sharespace.top/privkey.pem; 
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers HIGH:!aNULL:!MD5;

        location / {
	root /usr/share/nginx/html;
	index index.html;
        }

 location = /ray {
      if ($http_upgrade != "websocket") {
          return 404;
      }
      proxy_redirect off;
      proxy_pass http://127.0.0.1:10000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host $host;
      # Show real IP in v2ray access.log
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
 location ~ \.git { return 404; }

}

server {
    listen       80;
    server_name vpn.sharespace.top;
    if ($host = vpn.sharespace.top) {
        return 301 https://$host$request_uri;
    }
    return 404;
}

将 vpn.sharespace.top 换成自己的域名,并安装https证书,参考:https://tech.sharespace.top/certbot/

检查语法重启nginx

nginx -t && systemctl restart nginx

安装v2ray客户端软件使用我们的代理

到 https://github.com/2dust/v2rayN/releases 下载 v2rayN-Core.zip 最新版

添加节点

打赏微海报分享
标签: 暂无
最后更新:2023年6月23日

nico

Linux运维工程师 软考网络工程师 && 软考信息安全工程师

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

nico

Linux运维工程师
软考网络工程师 && 软考信息安全工程师

最新 热点 随机
最新 热点 随机
linux部署JDK环境 [Solved] MariaDB import issue: Error at line 1: Unknown command '\-'. Could not retrieve mirrorlist http://mirrorlist.centos.org/ CentOS 7 Kubernetes如何删除卡在“Terminating”状态的命名空间 解决GitLab Runner签名无效 如何禁用 Ubuntu "Daemons using outdated libraries" 弹出窗口
DNSX 和 Subfinder:强大的子域名枚举工具 Nginx: SSL_do_handshake() failed… and that’s OK! Linux 部署v2ray 清除Linux内存缓存和交换空间的方法 搭建tinyproxy代理 如何禁用 Ubuntu "Daemons using outdated libraries" 弹出窗口
最近评论
woodcockkienzlelsj8o9+73s48g9rr3m0@gmail.com 发布于 10 个月前(07月17日) necessitatibus corporis et odit nam quo harum et c...
RonaldG 发布于 10 个月前(07月07日) Very interesting topic, thank you for putting up.&...
小黑 发布于 1 年前(12月28日) 不错
nico 发布于 2 年前(02月09日) 嘻嘻嘻!!!
Bruse 发布于 2 年前(02月09日) 我来啦!!!
nico 发布于 2 年前(12月10日) 方便查询
Justin 发布于 2 年前(12月10日) 写的很好,谢谢分享!我 Mark 一下~
nico 发布于 3 年前(11月18日) 主题的原因吧
Justin 发布于 3 年前(09月22日) 这篇文章的质量很高呀!写得很详细~ 话说你的文章是隐藏了发布时间吗?
Justin 发布于 3 年前(08月27日) 好家伙,这标题乍一看还以为你打算进军英文技术写作领域了🤓

COPYRIGHT © 2023 Technology Sharing. ALL RIGHTS RESERVED.

备案图标 皖公网安备34132402000202 皖ICP备2023004851号-1