前言:由于近期GFW大肆封杀ss,导致大量的vps挂掉,其中我的也中招了,我也就是查查技术资料,看看youtube,可惜的是被干掉了,并且我的vps也就此挂到,让我十分苦恼,最近发现V2ray ws + tls科学上网,是模拟的https请求,这种请求目前GFW并不能很好的识别,遂开启的 V2ray之旅
由于希望保持vps的干净度,这里选择docker的方式安装,V2ray在hub.docker.com有官方的镜像,更新也比较及时
我这里比较熟悉使用centos 7,所以选择centos 7的系统
1,docker及docker compose安装
yum install docker-ce docker-compose -y systemctl enable docker systemctl start docker
2,拉去V2ray镜像
docker pull v2ray/official
3,创建配置文件
#创建配置文件目录 mkdir -pv /etc/v2ray #创建配置文件,id可以通过工具生成,工具地址https://1024tools.com/uuid,客户端这个id要跟服务端一样,千万不能配错 vi /etc/v2ray/config.json { "inbounds": [ { "port": 10000, "listen":"0.0.0.0", "protocol": "vmess", "settings": { "clients": [ { "id": "5abbc215-c243-46bc-99c7-103fa299aaaa", "alterId": 64 } ] }, "streamSettings": { "network": "ws", "wsSettings": { "path": "/ray" } } } ], "outbounds": [ { "protocol": "freedom", "settings": {} } ] }
4,配置docker-compose并启动
#编写docker-compose配置 version: '2' services: jenkins: container_name: v2ray image: v2ray/official restart: always environment: LANG: en_US.utf8 LC_ALL: en_US.utf8 ports: - "127.0.0.1:10000:10000" volumes: - "/etc/v2ray:/etc/v2ray" - "/etc/localtime:/etc/localtime:ro" #启动V2ray docker-compose up -d
完成上述操作就说明已经部署好服务端了
5,配置域名解析,CDN,反向代理
免费CDN:cloudflare.com 传送门:https://dash.cloudflare.com/ 按照要求注册即可
进入阿里云域名管理,选择域名,并点击管理进入域名基本信息页面
等大约10分钟之后回到cloudflare,点击完成,检查nameservers
做完域名解析+CDN后,我们在ping我们的主机域名,发现已经可以正常通信了,这就说明CDN代理生效了,下面开始配置nginx
安装就不说了,比较简单yum install nginx -y即可
#编辑配置文件 vi /etc/nginx/conf.d/v2ray.conf server { listen 80; server_name mydomain.me; #enforce https return 301 https://gaea.smszhd.com$request_uri; } server { listen 443 ssl; #listen 80; server_name mydomain.me; ssl on; ssl_certificate ssl/mydomain.me/fullchain1.pem; ssl_certificate_key ssl/mydomain.me/privkey1.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; location /ray { 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 $http_host; # Show realip in v2ray access.log proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } access_log logs/gaea.log main; } #启动nginx systemctl restart nginx
6,下载并安装客户端
#windows V2rayN :https://github.com/2dust/v2rayN/releases #mac brew cask install v2rayu #导入客户端配置 { "inbounds": [ { "port": 1080, "listen": "127.0.0.1", "protocol": "socks", "sniffing": { "enabled": true, "destOverride": ["http", "tls"] }, "settings": { "auth": "noauth", "udp": false } } ], "outbounds": [ { "protocol": "vmess", "settings": { "vnext": [ { "address": "mydomain.me", "port": 443, "users": [ { "id": "5abbc215-c243-46bc-99c7-103fa299aaaa", "alterId": 64 } ] } ] }, "streamSettings": { "network": "ws", "security": "tls", "wsSettings": { "path": "/ray" } } } ] }
启动客户端导入配置文件,就可以使用了