去官网看到linux的安装脚本,照着做就行:
# bash <(curl -L -s https://install.direct/go.sh)
Installing V2Ray v4.22.1 on x86_64
Downloading V2Ray: https://github.com/v2ray/v2ray-core/releases/download/v4.22.1/v2ray-linux-64.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 608 100 608 0 0 658 0 --:--:-- --:--:-- --:--:-- 658
100 11.6M 100 11.6M 0 0 2524k 0 0:00:04 0:00:04 --:--:-- 3573k
Extracting V2Ray package to /tmp/v2ray.
Archive: /tmp/v2ray/v2ray.zip
inflating: /tmp/v2ray/config.json
creating: /tmp/v2ray/doc/
inflating: /tmp/v2ray/doc/readme.md
inflating: /tmp/v2ray/geoip.dat
inflating: /tmp/v2ray/geosite.dat
creating: /tmp/v2ray/systemd/
inflating: /tmp/v2ray/systemd/v2ray.service
creating: /tmp/v2ray/systemv/
inflating: /tmp/v2ray/systemv/v2ray
inflating: /tmp/v2ray/v2ctl
extracting: /tmp/v2ray/v2ctl.sig
inflating: /tmp/v2ray/v2ray
extracting: /tmp/v2ray/v2ray.sig
inflating: /tmp/v2ray/vpoint_socks_vmess.json
inflating: /tmp/v2ray/vpoint_vmess_freedom.json
PORT:14583
UUID:b6329143-4355-4500-a17b-1d76e8ba8b39
Created symlink from /etc/systemd/system/multi-user.target.wants/v2ray.service to /etc/systemd/system/v2ray.service.
V2Ray v4.22.1 is installed.
记住上面的port和UUID
先不启动v2ray的程序。插一个nginx的搭建:
下面两步你要会通过letsencrypt来配置一个https的域名访问:
配置一个可以ssl访问的域名,通过letsencrypt配置证书:
acme.sh --issue -d moneyslow.com -d www.moneyslow.com --webroot /var/www/moneyslow/
copy证书到nginx配置文件的制定位置:
acme.sh --installcert -d moneyslow.com \
--key-file /etc/nginx/ssl/moneyslow.com.key \
--fullchain-file /etc/nginx/ssl/moneyslow.fullchain.cer \
--reloadcmd "systemctl restart nginx"
nginx的配置文件需要按这个来:
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/nginx/ssl/moneyslow.fullchain.cer;
ssl_certificate_key /etc/nginx/ssl/moneyslow.com.key;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
root /var/www/moneyslow;
index index.html;
server_name moneyslow.com;
location /var/www/moneyslow {
if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
return 404;
}
proxy_redirect off;
proxy_pass http://127.0.0.1:14583;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
# Show real IP in v2ray access.log
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
通过nginx -t检测语法没问题,重启能通过网页访问就可以了。
好了,nginx搞定。
下面的配置文件是/etc/v2ray/config.json,照着填就可以了,换port和id:
{
"log": {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"
},
"inbounds": [
{
"port": 14583,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "b6389143-4355-4300-a17b-1d76e8ba8b39",
"level": 1,
"alterId": 64
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/var/www/moneyslow"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {},
"tag": "direct"
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"routing": {
"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"
}
]
}
}
现在可以启动v2ray了:systemctl start v2ray
看看进程在就好。服务器端搞定。
下面是客户端,你通过一定的手段下载到客户端就行,参考:https://v2ray.com/awesome/tools.html
比如mac下v2rayU客户端的配置是这样的,里面填的和服务器端配置文件config.json要一样:
解释一下“传输配置“,这个其实就是伪装的方法,里面的各个选项的意思:
tcp:tcp传输方式
h2: http/2 的传输方式
ws: WebSocket 传输方式(因为我们配置里nginx域名代理转发,所以就选这个)
kcp: mKCP 使用 UDP 来模拟 TCP 连接
domainsocket: Domain Socket 使用标准的 Unix domain socket 来传输数据。它的优势是使用了操作系统内建的传输通道,而不会占用网络缓存。相比起本地环回网络(local loopback)来说,Domain socket 速度略快一些。目前仅可用于支持 Unix domain socket 的平台,如 macOS 和 Linux。在 Windows 上不可用。
quic: QUIC 全称 Quick UDP Internet Connection,是由 Google 提出的使用 UDP 进行多路并发传输的协议。其主要优势是:
减少了握手的延迟(1-RTT 或 0-RTT)
多路复用,并且没有 TCP 的阻塞问题
连接迁移,(主要是在客户端)当由 Wifi 转移到 4G 时,连接不会被断开。
QUIC 目前处于实验期,使用了正在标准化过程中的 IETF 实现,不能保证与最终版本的兼容性。
当然了,最快还是直接一个协议,因为: