V2ray websocket(ws)+tls+nginx分流

一、准备域名
这里http://www.dot.tk/en/index.html?lang=en,可免费申请域名。按Use DNSIP address设定为VPSIP地址。

二、安装v2ray nginx
1、安装wget unzip daemon
apt install unzip daemon jq wget vim
2、安装v2ray
bash <(curl -L -s https://install.direct/go.sh)
记录portUUID
比如:
PORT:28434
UUID:d38c9abd-dacc-4aee-bab5-6fd44c9fc324

3、安装EasyEngine,它內置了 Nginx Let’s Encrypt
wget -qO ee rt.cx/ee && sudo bash ee
安装中需要输入名字和邮箱,安装完需要如下命令使用
source /etc/bash_completion.d/ee_auto.rc
使用如下命令申请Let’s Encrypt ssl证书
ee site create xuefliang.ga html letsencrypt
出现错误,使用如下命令进行查看
cat /var/log/letsencrypt/letsencrypt.log
4、将v2ray加入nginx,需要需改红色的端口号
vim /var/www/xuefliang.ga/conf/nginx/v2ray.conf
location /enterv2ray/ {
proxy_redirect off;
proxy_pass http://127.0.0.1:28434;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
5、创建检查的网页,如无错误,可以通过浏览器访问xueflaing.ga
cp /var/www/html/index.nginx-debian.html /var/www/xuefliang.ga/htdocs/index.html && chown  www-data: /var/www/xuefliang.ga/htdocs/index.html
启用nginx
service nginx restart
三、v2ray服务端配置
rm /etc/v2ray/config.json && vim /etc/v2ray/config.json
需修改原本的 UUID port.
{
       "log": {
              "access": "/var/log/v2ray/access.log",
              "error": "/var/log/v2ray/error.log",
              "loglevel": "warning"
       },
       "inbound": {
              "port": 28434,
              "protocol": "vmess",
              "settings": {
                     "clients": [{
                                   "id": "d38c9abd-dacc-4aee-bab5-6fd44c9fc324",
                                   "level": 1,
                                   "alterId": 64,
                                   "security": "auto"
                            }
                     ]
              },
              "streamSettings": {
                     "network": "ws",
                     "security": "auto",
                     "wsSettings": {
                            "path": "/enterv2ray/"
                     }
              }
       },
       "outbound": {
              "protocol": "freedom",
              "settings": {}
       },
       "outboundDetour": [{
                     "protocol": "blackhole",
                     "settings": {},
                     "tag": "blocked"
              }
       ],
       "routing": {
              "strategy": "rules",
              "settings": {
                     "rules": [{
                                   "type": "field",
                                   "ip": [
                                          "0.0.0.0/8",
                                          "10.0.0.0/8",
                                          "100.64.0.0/10",
                                          "127.0.0.0/8",
                                          "169.254.0.0/16",
                                          "172.16.0.0/12",
                                          "192.0.0.0/24",
                                          "192.0.2.0/24",
                                          "192.168.0.0/16",
                                          "198.18.0.0/15",
                                          "198.51.100.0/24",
                                          "203.0.113.0/24",
                                          "::1/128",
                                          "fc00::/7",
                                          "fe80::/10"
                                   ],
                                   "outboundTag": "blocked"
                            }
                     ]
              }
       }
}
检查配置文件是否书写争取
jq . /etc/v2ray/config.json
启用v2ray
service v2ray restart

四、v2ray客户端配置

{
       "log": {
              "loglevel": "info"
       },
       "inbound": {
              "protocol": "socks",
              "listen": "127.0.0.1",
              "port": 1080,
              "settings": {
                     "auth": "noauth",
                     "udp": true,
                     "timeout": 30
              }
       },
       "inboundDetour": [],
       "outbound": {
              "protocol": "vmess",
              "settings": {
                     "vnext": [{
                                   "address": "xuefliang.ga",
                                   "port": 443,
                                   "users": [{
                                                 "id": "d38c9abd-dacc-4aee-bab5-6fd44c9fc324",
                                                 "alterId": 64,
                                                 "security": "auto"
                                          }
                                   ]
                            }
                     ]
              },
              "mux": {
                     "enabled": true
              },
              "streamSettings": {
                     "network": "ws",
                     "security": "tls",
                     "tlsSettings": {
                            "serverName": "xuefliang.ga",
                            "allowINsecure": true
                     },
                     "wsSettings": {
                            "path": "/enterv2ray/"
                     }
              }
       },
       "outboundDetour": [{
                     "protocol": "freedom",
                     "settings": {},
                     "tag": "direct"
              }
       ],
       "dns": {
              "servers": [
                     "8.8.8.8",
                     "8.8.4.4"
              ]
       },
       "routing": {
              "strategy": "rules",
              "settings": {
                     "domainStrategy": "IPIfNonMatch",
                     "rules": [{
                                   "type": "field",
                                   "ip": [
                                          "0.0.0.0/8",
                                          "10.0.0.0/8",
                                          "100.64.0.0/10",
                                          "127.0.0.0/8",
                                          "169.254.0.0/16",
                                          "172.16.0.0/12",
                                          "192.0.0.0/24",
                                          "192.0.2.0/24",
                                          "192.168.0.0/16",
                                          "198.18.0.0/15",
                                          "198.51.100.0/24",
                                          "203.0.113.0/24",
                                          "::1/128",
                                          "fc00::/7",
                                          "fe80::/10"
                                   ],
                                   "outboundTag": "direct"
                            }
                     ]
              }
       }
}

五、安装加速
1KVM内核
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh
chmod +x bbr.sh
./bbr.sh
2openvz内核
wget https://raw.githubusercontent.com/kuoruan/shell-scripts/master/ovz-bbr/ovz-bbr-installer.sh
chmod +x ovz-bbr-installer.sh
./ovz-bbr-installer.sh

加速端口为443 和服务器端口

评论

此博客中的热门博文

Rstudio 使用代理