事前准备
一台VPS(系统Ubuntu 16.04),一个域名(提前做好解析),SSH工具
部署过程
安装V2Ray
SSH连接上远程VPS后,首先执行官方安装脚本:
bash <(curl -L -s https://install.direct/go.sh)
在安装完V2Ray之后,修改配置文件重启V2Ray即可,配置文件路径为
/etc/v2ray/config.json
以下是V2Ray使用的命令:
sudo service v2ray start #启动V2Ray
sudo service v2ray stop #停止运行V2Ray
sudo service v2ray restart #重启V2Ray
sudo service v2ray status #查看V2Ray状态
安装宝塔BT面板
根据VPS具体系统选择相应一键安装脚本,本教程以 Ubuntu 16.04为例:wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh
安装完成后,记录终端自动生成的账户密码,然后浏览器登录BT面板操作,建议初次登陆后修改用户名和密码。
安装LNMP环境+Nignx配置
登录BT面板后,可一键部署源码,选择安装LNMP环境;
一切都安装完后,点击「网站」——「添加站点」
![](https://injoy-1254269953.cos.ap-shanghai.myqcloud.com/006tKfTcgy1fsl27mamvfj30hr0f1jsh.jpg)
成功添加完站点后,点击「设置」—— SSL —— Let’s Encrypt,成功申请SSL后,保存
![](https://injoy-1254269953.cos.ap-shanghai.myqcloud.com/006tKfTcgy1fsl28m5lo4j30sc0ht0ty.jpg)
再点击站点「设置」的「配置文件」选项,在ssl最后一个}前添加如下代码:
location /ws {
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_intercept_errors on;
if ($http_upgrade = "websocket" ){
proxy_pass http://127.0.0.1:****; #自定义端口,与下同
}
}
回到「首页」,重启「Nignx服务」
BT面板「安全」,防火墙端口放行,新增你的V2Ray端口
![](https://injoy-1254269953.cos.ap-shanghai.myqcloud.com/006tKfTcgy1fsl2q03jk0j30kr01ygls.jpg)
修改V2Ray配置文件
打开面板「文件」,在路径中输入“/etc/v2ray”,编辑以下文件,并保存
{
"log" : {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "info"
},
"inbounds": [
{
"port": 0000, #v2Ray访问端口,自定义
"listen":"127.0.0.1",
"protocol": "vmess",
"allocate": {
"strategy": "always"
},
"settings": {
"clients": [
{
"id": "UUID", #自定义UUID
"alterId": 64,
"level": 1,
"security": "aes-cfb-128" #自定义加密方式
}
]
},
"streamSettings": {
"network":"ws",
"wsSettings": {
"connectionReuse": false,
"path": "/ws/" #自定义路径
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
],
"outboundDetour": [
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"routing": {
"strategy": "rules",
"settings": {
"rules": [
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "blocked"
}
]
}
}
}
重启V2Ray服务
service v2ray restart
service v2ray status #通过该命令,可查看v2ray是否运行成功