本教程参考 https://toutyrater.github.io/advanced/wss_and_web.html ,且已修正原文 Nginx 配置中的一处错误。另,本教程不适合零基础小白。
安装 V2Ray
参考: https://www.v2ray.com/chapter_00/install.html
运行以下脚本安装 V2Ray 。
bash <(curl -L -s https://install.direct/go.sh)
修改 V2Ray 配置文件
mv /etc/v2ray/config.json /etc/v2ray/config.json.bak
vim /etc/v2ray/config.json
PLEASE REPLACE THE UUID in the following config sample!!!
{
"inbounds": [
{
"port": 10000,
"listen":"127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "6865972c-f50e-4153-8f0d-e63c56f0f468",
"alterId": 64
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/ray"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
systemctl restart v2ray
配置 Nginx
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name your.domain;
location / {
try_files $uri $uri/ =404;
}
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";
# Show realip in v2ray access.log
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
# fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
#}
location ~ /\.ht {
deny all;
}
}
接下来用 certbot 配 TLS ,不详细说了 ,你也可以直接在上面的配置文件中弄好 TLS 。
此外,还可以用 ufw 把 10000 端口墙掉,增加安全性。
还可以再套一层 CDN ,例如 CloudFlare , 大陆稳稳的 20Mbps , 但不推荐这样做,被判定为滥用后果自负。
客户端
选择
个人在 Windows 端使用的是 v2rayN ,iOS 端使用 Shadowrocket,Andriod 端未知,MacOS 端未知。
配置
配置可在下方二维码基础上进行必要修改
vmess://ew0KICAidiI6ICIyIiwNCiAgInBzIjogInNhbXBsZSIsDQogICJhZGQiOiAieW91ci5kb21haW4iLA0KICAicG9ydCI6ICI0NDMiLA0KICAiaWQiOiAiNjg2NTk3MmMtZjUwZS00MTUzLThmMGQtZTYzYzU2ZjBmNDY4IiwNCiAgImFpZCI6ICI2NCIsDQogICJuZXQiOiAid3MiLA0KICAidHlwZSI6ICJub25lIiwNCiAgImhvc3QiOiAiIiwNCiAgInBhdGgiOiAiL3JheSIsDQogICJ0bHMiOiAidGxzIg0KfQ==
发表评论