Project V 是一个工具集合,它可以帮助你打造专属的基础通信网络。Project V 的核心工具称为V2Ray,其主要负责网络协议和功能的实现,与其它 Project V 通信。V2Ray 可以单独运行,也可以和其它工具配合,以提供简便的操作流程。

GitHub:https://github.com/v2ray/v2ray-core
官网:https://www.v2ray.com
客户端下载:https://github.com/v2ray/v2ray-core/releases

V2Ray 在以下平台中可用:

Windows 7 及之后版本(x86 / amd64);
Mac OS X 10.10 Yosemite 及之后版本(amd64);
Linux 2.6.23 及之后版本(x86 / amd64 / arm / arm64 / mips64 / mips);
包括但不限于 Debian 7 / 8、Ubuntu 12.04 / 14.04 及后续版本、CentOS 6 / 7、Arch Linux;
FreeBSD (x86 / amd64);
OpenBSD (x86 / amd64);
Dragonfly BSD (amd64);

Linux 安装脚本

V2Ray 提供了一个在 Linux 中的自动化安装脚本。这个脚本会自动检测有没有安装过 V2Ray,如果没有,则进行完整的安装和配置;如果之前安装过 V2Ray,则只更新 V2Ray 二进制程序而不更新配置。

运行下面的指令下载并安装 V2Ray。当 yum 或 apt-get 可用的情况下,此脚本会自动安装 unzip 和 daemon。这两个组件是安装 V2Ray 的必要组件。如果你使用的系统不支持 yum 或 apt-get,请自行安装 unzip 和 daemon

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 的运行。

config.json格式

}
  "log": {},
  "api": {},
  "dns": {},
  "stats": {},
  "routing": {},
  "policy": {},
  "reverse": {},
  "inbounds": [],
  "outbounds": [],
  "transport": {}
}

服务器config.json的配置

{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbounds": [{
    "port": port,
    "listen":"127.0.0.1",
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "UUID",
          "level": 1,
          "alterId": 64
        }
      ]
    },
    "streamSettings": {
        "network": "ws",
        "wsSettings": {
            "connectionReuse": true,
            "path": "/proxy/path"
        }
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}

port:v2ray监听端口,如果使用Nginx端口转发需要做对应设置
id:输入一个UUID,可在UUID Generator生成一个,服务端和客户端要一致
path:我用的是ws协议,此路径为虚拟网站路径,需要在Nginx里定义

修改好后运行:service v2ray restart启动服务

Nginx.conf配置

    location /proxy/path {
        proxy_redirect             off;
        proxy_pass                 http://127.0.0.1:port;
        proxy_http_version         1.1;
        proxy_set_header           Upgrade $http_upgrade;
        proxy_set_header           Connection "upgrade";
        proxy_set_header           Host $http_host;
    }

修改完成后运行:service nginx reload重新加载配置文件

客户端config.json配置

{
  "log": {
    "loglevel": "warning"
  },
  "inbounds": [{
    "port": 1080,
    "listen": "127.0.0.1",
    "tag": "socks-inbound",
    "protocol": "socks",
    "settings": {
      "auth": "noauth",
      "udp": false,
      "ip": "127.0.0.1"
    },
    "sniffing": {
      "enable": true,
      "destOverride": ["http", "tls"]
    },
    "allocate": {
      "strategy": "always",
      "refresh": 5,
      "concurrency": 3
    }
  },{
    "port": 1082,
    "listen": "127.0.0.1",
    "tag": "http-inbound",
    "protocol": "http",
    "settings": {
      "auth": "noauth",
      "udp": false,
      "ip": "127.0.0.1"
    },
    "sniffing": {
      "enable": true,
      "destOverride": ["http", "tls"]
    },
    "allocate": {
      "strategy": "always",
      "refresh": 5,
      "concurrency": 3
    }
  }],
  "outbounds": [{
    "protocol": "vmess",
    "settings": {
      "vnext": [
        {
          "address": "you.domain",
          "port": 443,
          "users": [
            {
              "id": "UUID",
              "alterId": 64,
              "security": "auto",
              "level": 1
            }
          ]
        }
      ]
    },
    "tag": "out-Proxy",
    "streamSettings": {
      "network": "ws",
      "security": "tls",
      "tlsSettings": {
        "serverName": "you.domain"
      },
      "wsSettings": {
        "path": "/proxypath"
      }
    },
    "mux": {
      "enabled": true,
      "concurrency": 8
    }
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  },{
    "protocol": "freedom",
    "settings": {},
    "tag": "direct"
  }],
  "routing": {
    "domainStrategy": "IPOnDemand",
    "rules":[
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      },
      {
        "type": "field",
        "domain": ["geosite:category-ads"],
        "outboundTag": "blocked"
      },
      {
        "type": "field",
        "domain": [
          "360.com",
          "360.cn",
          "api.map.baidu.com",
          "ps.map.baidu.com",
          "sv.map.baidu.com",
          "offnavi.map.baidu.com",
          "newvector.map.baidu.com",
          "ulog.imap.baidu.com",
          "newloc.map.n.shifen.com",
          "api.map.baidu.com",
          "ps.map.baidu.com",
          "sv.map.baidu.com",
          "offnavi.map.baidu.com",
          "newvector.map.baidu.com",
          "ulog.imap.baidu.com",
          "newloc.map.n.shifen.com"
        ],
        "ip": [
          "14.63.198.45/32",
          "23.42.186.24/32",
          "23.66.147.48/32",
          "59.110.16.35/32",
          "101.227.12.0/23",
          "101.227.14.0/24",
          "101.227.119.0/24",
          "101.227.200.0/24",
          "106.11.11.86/32",
          "107.20.211.189/32",
          "108.61.200.51/32",
          "111.63.135.0/24",
          "111.206.13.60/30",
          "111.206.13.64/28",
          "111.206.13.80/32",
          "111.206.13.250/31",
          "111.206.22.0/24",
          "113.207.57.24/32",
          "115.29.247.48/32",
          "116.206.22.7/32",
          "117.34.51.0/24",
          "119.188.13.0/24",
          "120.26.151.246/32",
          "120.55.199.139/32",
          "120.76.189.132/32",
          "120.77.11.172/32",
          "120.132.63.203/32",
          "121.42.144.95/32",
          "121.43.75.169/32",
          "121.201.11.95/32",
          "121.201.108.2/32",
          "121.251.255.0/24",
          "122.72.50.17/32",
          "122.226.223.163/32",
          "123.57.94.184/32",
          "123.125.111.0/24",
          "123.125.117.0/24",
          "123.125.118.0/24",
          "123.206.1.246/32",
          "124.116.241.0/24",
          "140.205.36.26/32",
          "180.76.155.58/32",
          "180.76.163.245/32",
          "180.76.171.28/32",
          "180.76.190.68/32",
          "182.48.119.159/32",
          "183.131.79.130/32",
          "211.137.132.89/32",
          "221.179.183.0/24",
          "221.179.191.0/24"
        ],
        "outboundTag": "blocked"
      },
      {
        "type": "field",
        "domain": [
          "apple.com",
          "icloud.com",
          "itunes.com",
          "mzstatic.com",
          "icloud-content.com",
          "geosite:cn"
        ],
        "ip": [
          "geoip:cn"
        ],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": [
          "8.8.8.8"
        ],
        "outboundTag": "out-Proxy"
      },
      {
        "type": "chinasites",
        "outboundTag": "direct"
      },
      {
        "type": "chinaip",
        "outboundTag": "direct"
      }
    ]
  },
  "dns": {
    "hosts": {
      "domain:360.com": "127.0.0.1"
    },
    "servers": [
      "1.1.1.1",
      {
        "address": "114.114.114.114",
        "port": 53,
        "domains": [
          "geosite:cn"
        ]
      },
      "8.8.8.8",
      "localhost"
    ]
  },
  "policy": {
    "levels": {
      "0": {
        "uplinkOnly": 0,
        "downlinkOnly": 0
      }
    },
    "system": {
      "statsInboundUplink": false,
      "statsInboundDownlink": false
    }
  },
  "other": {}
}

标签:无

你的评论