本文最后更新于:2020年5月12日 下午
V2ray 安装及配置
V2ray 安装及配置
一键安装
bash <(curl -L -s https://install.direct/go.sh)######此脚本会自动安装以下文件:
- /usr/bin/v2ray/v2ray:V2Ray 程序;
- /usr/bin/v2ray/v2ctl:V2Ray 工具;
- /etc/v2ray/config.json:配置文件;
- /usr/bin/v2ray/geoip.dat:IP 数据文件
- /usr/bin/v2ray/geosite.dat:域名数据文件
此脚本会配置自动运行脚本。自动运行脚本会在系统重启之后,自动运行 V2Ray。目前自动运行脚本只支持带有 Systemd 的系统,以及 Debian / Ubuntu 全系列。
运行脚本位于系统的以下位置:
/etc/systemd/system/v2ray.service: Systemd/etc/init.d/v2ray: SysV
脚本运行完成后,你需要:
编辑/etc/v2ray/config.json文件来配置你需要的代理方式;
运行 service v2ray start 来启动 V2Ray 进程;
之后可以使用 service v2ray start|stop|status|reload|restart|force-reload控制 V2Ray 的运行。
配置示范
- CADDY+ HTTP + V2RAY + TLS
{ "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", "loglevel": "none" }, "stats": {}, "policy": { "system": { "statsInboundDownlink": true, "statsInboundUplink": true }, "levels": { "1": { "statsUserUplink": true, "statsUserDownlink": true } } }, "api": { "services": [ "HandlerService", "LoggerService", "StatsService" ], "tag": "api" }, "levels": { "1": { "bufferSize": 40960 } }, "inbound": { "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] }, "udp": true, "port":8883 , "listen":"127.0.0.1", "protocol": "vmess", "settings": { "clients": [ { "id": "f6707c17-0000-0000-000-000000000", "level": 1, "alterId": 500, "security": "auto" } ] }, "streamSettings":{ "network":"ws", "security": "auto", "wsSettings":{ "path": "/path/" } }, "sockopt": { "mark": 0, "tcpFastOpen": true }, "tag": "KR" }, "inboundDetour": [ { "protocol": "dokodemo-door", "listen": "127.0.0.1", "settings": { "address": "127.0.0.1" }, "port": 9548, "tag": "api" } ], "outbound": { "protocol": "freedom", "settings": {} }, "outboundDetour": [ { "protocol": "blackhole", "settings": {}, "tag": "blocked" } ], "dns": { "servers": [ "https://dns.google/dns-query", "https://1.1.1.1/dns-query", "203.248.252.2", "164.124.101.2", "127.0.0.1" ] } , "routing": { "strategy": "rules", "settings": { "rules": [ { "inboundTag": [ "api" ], "outboundTag": "api", "type": "field" }, { "type": "field", "outboundTag": "block", "protocol": [ "bittorrent" ] }, { "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" } ] } } } - CADDY+ HTTP2 + V2RAY + TLS
{ "inbound": { "port": 8883, "listen": "127.0.0.1", "protocol": "vmess", "settings": { "clients": [ { "id": "f6707c17-00000-0000-0000-00000000000", "level": 1, "alterId": 64 } ] }, "streamSettings": { "network": "h2", "security": "tls", "httpSettings": { "path": "/apth", "host": "xxx.com" }, "tlsSettings": { "serverName": "xxx.com", "certificates": [ { "certificateFile": "/etc/v2ray/v2ray.crt", "keyFile": "/etc/v2ray/v2ray.key" } ] } } }, "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" } ] } } }
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!