搭建这个玩意确实挺麻烦,需要用到的知识也很多,比如说,购买vps,安装面板,或者直接安装,域名解析,套入cdn,指定IP等等。
今天这篇文章就用aapanel来搭建这一揽子玩意,感兴趣的可以围观。如果用的宝塔可以参考:v2ray搭建:宝塔面板
1、准备
1)域名:Namesilo域名注册和使用教程
2)vps:搬瓦工(Bandwagonhost)vps注册和购买
3)cloudflare账号:没有注册一个,https://www.cloudflare.com/
4)aapanel安装:[aaPanel Linux panel安装教程]
5)安装nginx:[aapanel install nginx]
2、配置aapanel
aapanel安装好之后,我们还需要做一些配置:
- 浏览器访问面板地址,输入账号密码登录
- 安装 LNMP 环境+Nignx 配置(可以后期搭建网站做转发)
- 只安装 nginx(不做网站转发,只做 ws)一般就安装一个nginx就可以了
- 添加站点。这个站点就是你 v2ray 软件里的代理地址。
3、新建站点
1)[aapanel新建站点]
2)接下来进入 修改网站配置文件 点击配置文件,找到 #SSL-END
,大概在 27 行左右,在其下面添加如下代码
location /ou { proxy_pass http://127.0.0.1:你的端口号; 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; proxy_read_timeout 300s; }
看图:

注意:
- 这里默认的端口用49100
- 其中第一行的 ou是你自己 ws 的 path,斜杠不要删除,可以自己修改,也可以不改
- 端口号我们这里先随便写一个比如:41900,因为现在 v2ray 官方不为你生成端口
3)放行端口,宝塔安全处放行49100端口
看教程:[aapanel Accept port(放行端口)]
接下来就是本文重点了,我们开始安装 v2ray 最新官方脚本
注意:全文采用操作系统为 centos 7
4、安装依赖软件
1)安装 cURL:
yum makecache yum install curl
2)下载脚本
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
5、使用
1)安裝和更新 V2Ray
bash install-release.sh
2)安裝最新發行的 geoip.dat 和 geosite.dat
bash install-dat-release.sh
3)生成随机 UUID
cat /proc/sys/kernel/random/uuid # 粘贴到 VPS 运行即可生成 UUID,并将 UUID 粘贴到以下代码中
4)进入 /usr/local/etc/v2ray/ 目录,编辑 config.json 文件 将里面全部代码改为:
[reply]
注意:
- port这里修改为自己设定的的端口,默认是49100~
- uuid,填写好,你的域名别忘了写。
{ "inbounds": [{ "port": 49100, "listen": "127.0.0.1", "protocol": "vmess", "settings": { "clients": [ { "id": "你的uuid", "level": 1, "alterId": 0 } ], "disableInsecureEncryption": false }, "streamSettings": { "network": "ws", "wsSettings": { "path": "/ou", "headers": { "Host": "你的域名" } } } }], "outbounds": [{ "protocol": "freedom", "settings": {} },{ "protocol": "blackhole", "settings": {}, "tag": "blocked" }], "routing": { "rules": [ { "type": "field", "ip": ["geoip:private"], "outboundTag": "blocked" } ] } }
[/reply]
5)设置开机启动
systemctl enable v2ray systemctl start v2ray
大功告成!之后设置客户端就可以愉快的玩耍了~如果要查询状态等,可以用下面的命令。
systemctl restart v2ray systemctl status v2ray
6、设置客户端
1)接入cdn
这里用的是cloudflare,前面我们的域名是放在cloudflare托管,那么这个时候点亮橘色的云朵,即可接入cdn了。
2)客户端设置,看图:

7、最后
如果你不是准备卸载 V2ray ,这条命令你可以忽略,不要执行!
bash install-release.sh --remove
參數
usage: install-release.sh [--remove | --version number | -c | -f | -h | -l | -p] [-p address] [--version number | -c | -f] --remove Remove V2Ray --version Install the specified version of V2Ray, e.g., --version v4.18.0 -c, --check Check if V2Ray can be updated -f, --force Force installation of the latest version of V2Ray -h, --help Show help -l, --local Install V2Ray from a local file -p, --proxy Download through a proxy server, e.g., -p http://127.0.0.1:8118 or -p socks5://127.0.0.1:1080
未经允许不得转载:mis笔记 » v2ray搭建:aapanel+vmess+ws+tls+nginx+cdn
试试评论~~
过来学习!