环境介绍

基于GreenCloud Japan KVM VPS JP-1配置演示搭建,主要参数如下

OS Ubuntu 18.04 LTS (GNU/Linux 4.15.0-20-generic x86_64)
CPU 1core @ 2.7GHz
RAM 1GB
SSD 15GB RAID-10
架构 KVM

安装v2ray与Nginx

使用官方推荐的方式安装v2ray:bash <(curl -L -s https://install.direct/go.sh) 

使用lnmp一键安装包安装lnmp环境(使用Nginx是因为同一台服务器上需要使用Nginx提供的其他服务,如果仅仅是需要实现ws+tls伪装加密,建议使用Caddy,更加小巧且会自动申请证书并自动更新,更加方便)。

配置Nginx

假设使用tokyo.39hope.com作为连接的域名。执行lnmp vhost add  创建初始配置,添加SSL时选择是会自动生成配置好SSL的配置文件。然后编辑配置文件:/usr/local/nginx/conf/vhost/tokyo.39hope.com.conf

(可选)删除80端口的监听,然后删除443端口下全部location的内容,改为一下内容:

  1. location / {  
  2.             #向后端传递访客IP  
  3.             proxy_set_header X-Real-IP $remote_addr;  
  4.             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
  5.             #设定需要反代的域名,可以加端口号  
  6.             proxy_pass https://github.com/;  
  7.             #替换网站内容  
  8.             sub_filter ‘https://github.com/’ ‘tokyo.39hope.com’;  
  9.             # websocket设定,V2ray使用,这里的设置要和v2ray的设置一致,对于 V2Ray/ray  /ray/ 是不一样的  
  10.             location /astral {  
  11.                 proxy_redirect off;  
  12.                 #proxy_pass http://127.0.0.1:10000;  
  13.                 proxy_http_version 1.1;  
  14.                 proxy_set_header Upgrade $http_upgrade;  
  15.                 proxy_set_header Connection “upgrade”;  
  16.                 proxy_set_header Host $http_host;  
  17.                 proxy_intercept_errors on;  
  18.                 if ($http_upgrade = “websocket” ){  
  19.                     proxy_pass http://127.0.0.1:10000;  
  20.                 }  
  21.             }  
  22.         }  

重启Nginx服务:/usr/local/nginx/sbin/nginx -s reload  ,然后尝试访问https://tokyo.39hope.com 成功显示GitHub界面即为设置成功。

配置v2ray

最后修改v2ray配置:/etc/v2ray/config.json  

  1. {  
  2.     “log”: {  
  3.         “loglevel”“warning”,  
  4.         “access”“/var/log/v2ray/access.log”,  
  5.         “error”“/var/log/v2ray/error.log”  
  6.     },  
  7.     “inbounds”: [  
  8.         {  
  9.             “port”10000,  
  10.             “listen”“127.0.0.1”,  
  11.             “protocol”“vmess”,  
  12.             “settings”: {  
  13.                 “clients”: [  
  14.                     {  
  15.                         “id”“b831381d-6324-4d53-ad4f-8cda48b30811”,  
  16.                         “alterId”64  
  17.                     }  
  18.                 ]  
  19.             },  
  20.             “streamSettings”: {  
  21.                 “network”:“ws”,  
  22.                 “wsSettings”: {  
  23.                     “path”“/astral”  
  24.                 }  
  25.             }  
  26.         }  
  27.     ],  
  28.     “outbounds”: [  
  29.         {  
  30.             “protocol”“freedom”,  
  31.             “settings”: {}  
  32.         }  
  33.     ]  
  34. }  

完成后使用service v2ray start 启动服务,配置完成

作者 Assaultcore

发表回复

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