Coder Social home page Coder Social logo

v2ray-guide's Introduction

V2Ray 配置指南

声明

V2Ray 配置指南(下称本指南)是网友自发编写的关于 V2Ray 如何配置及使用的指南,与 V2Ray 官方并无任何关系。尽管 V2Ray 厚爱将本指南的链接放到了其官网首页,这并不意味着本指南的建议或推荐为 V2Ray 官方所主张。

简介

什么是 V2Ray?

V2Ray 是 Project V 下的一个工具。Project V 是一个包含一系列构建特定网络环境工具的项目,而 V2Ray 属于最核心的一个。 官方中介绍Project V 提供了单一的内核和多种界面操作方式。内核(V2Ray)用于实际的网络交互、路由等针对网络数据的处理,而外围的用户界面程序提供了方便直接的操作流程。不过从时间上来说,先有 V2Ray 才有 Project V。 如果还是不理解,那么简单地说,V2Ray 是一个与 Shadowsocks 类似的代理软件,可以用来科学上网(翻墙)学习国外先进科学技术。

V2Ray 用户手册:https://www.v2ray.com(已被墙) https://v2ray.cool(已被墙)

V2Ray 项目地址:https://github.com/v2ray/v2ray-core

V2Ray Telegram 使用群链接:https://t.me/projectv2ray

V2Ray 跟 Shadowsocks 有什么区别?

区别还是有的,Shadowsocks 只是一个简单的代理工具,而 V2Ray 定位为一个平台,任何开发者都可以利用 V2Ray 提供的模块开发出新的代理软件。

了解 Shadowsocks 历史的同学都知道,Shadowsocks 是 clowwindy 开发的自用的软件,开发的初衷只是为了让自己能够简单高效地科学上网,自己使用了很长一段时间后觉得不错才共享出来的。V2Ray 是 clowwindy 被喝茶之后 V2Ray 项目组为表示抗议开发的,一开始就致力于让大家更好更快的科学上网。

由于出生时的历史背景不同,导致了它们性格特点的差异。

简单来说,Shadowsocks 功能单一,V2Ray 功能强大。听起来似乎有点贬低 Shadowsocks 呢?当然不!换一个角度来看,Shadowsocks 简单好上手,V2Ray 复杂配置多。

既然 V2Ray 复杂,为什么要用它?

童鞋,某事物的优点和缺点总是相生相随的。相对来说,V2Ray 有以下优势:

  • 更完善的协议: V2Ray 使用了新的自行研发的 VMess 协议,改正了 Shadowsocks 一些已有的缺点,更难被墙检测到
  • 更强大的性能: 网络性能更好,具体数据可以看 V2Ray 官方博客
  • 更丰富的功能: 以下是部分 V2Ray 的功能
    • mKCP: KCP 协议在 V2Ray 上的实现,不必另行安装 kcptun
    • 动态端口:动态改变通信的端口,对抗对长时间大流量端口的限速封锁
    • 路由功能:可以随意设定指定数据包的流向,去广告、反跟踪都可以
    • 传出代理:看名字可能不太好理解,其实差不多可以称之为多重代理。类似于 Tor 的代理
    • 数据包伪装:类似于 Shadowsocks-rss 的混淆,另外对于 mKCP 的数据包也可伪装,伪装常见流量,令识别更困难
    • WebSocket 协议:可以 PaaS 平台搭建V2Ray,通过 WebSocket 代理。也可以通过它使用 CDN 中转,抗封锁效果更好
    • Mux:多路复用,进一步提高科学上网的并发性能

哪有十全十美的东西?

少年悟性很高啊!当然没有!目前来说,V2Ray 有下面的缺点:

  • 配置复杂
  • 产业链不成熟

为什么要写这篇文章?

虽然其文档很详细,换个说法就是很长,一般用户看到这么长的使用文档都有点望而却步。另外我用 Google 搜索过 V2Ray,搜出来的文章非常少,只能寥寥数篇,而且至少都是好几月之前的,由于 V2Ray 的迭代速度快,一些文章对目前的 V2Ray 已经不适用了。所以我希望通过本指南:

  • 让大家了解到最新的 V2Ray 是什么样子的
  • 让大家知道利用 V2Ray 可以做些什么
  • 尝试用浅显易懂的语言来讲解 V2Ray 的配置
  • 分享一些配置案例

然而最重要的是希望大家能够通过我写的配置指南看懂 V2Ray 的手册。

听你说了这么多,好像 V2Ray 还不错的样子。但我只是要翻翻墙而已,不想花太多时间怎么办?

无论做什么都是有代价的,付出不一定有收获,但是不付出肯定没有收获。

我决定尝试一下 V2Ray,那么我该如何使用这个指南?

V2Ray 的用户手册非常详细地解释了 V2Ray,本指南主要以实际可用的配置从易到难来讲解 V2Ray 的功能特性,力求降低新手使用 V2Ray 的难度。

本指南的目标用户是有一定的 Linux 操作基础,像怎么注册 VPS,怎么用 SSH 登录 VPS,怎么使用 nano(或 vim) 编辑一个文本以及一些 Linux 基本命令的使用件网上有一大堆的指南,没必要重复造轮子再写一篇教程,如果这些你不会,强烈建议你去学会了再来尝试搭建 V2Ray。

本指南可以看作 V2Ray 用户手册的简易版本,也可以看作 V2Ray 的应用举例。你可以在不参考 V2Ray 用户手册的情况下按照本指南的指导去搭建配置 V2Ray ,但我并不建议你这么做。因为本指南只是引导大家如何理解和配置 V2Ray,相较于用户手册来说有一定的取舍,会忽略一部分东西。所以我希望大家也花时间去阅读 V2Ray 用户手册。

刚开始使用 V2Ray,有什么需要注意的吗?

由于许多 V2Ray 用户都有使用过 Shadowsocks 的经验,基本上可以按照使用 Shadowsocks 那样使用。但是 V2Ray 还是和 Shadowsocks 不太一样,所以我大概说一下使用上的差异。请注意,差异不代表好坏或优劣,如果一个事物必须拥有其他同类所拥有的东西,那么它也就没有了存在的意义。

  • 客户端:V2Ray 本身只是一个内核,V2Ray 上的图形客户端大多是调用 V2Ray 内核套一个图形界面的外壳,类似于 Linux 内核和 Linux 操作系统的关系;而 Shadowsocks 的客户端都是自己重新实现了一遍 Shadowsocks 协议。本文的内容短期内不涉及图形客户端的使用。
  • 分流:也许大家第一反映是 PAC,实际上无论是 Shadowsocks (特指 Shadowsocks-libev) 还是 V2Ray 本身不支持 PAC,都是客户端加进来的;Shadowsocks 的分流使用 ACL,V2Ray 使用自己实现的路由功能,孰优孰劣只是仁者智者的问题。
  • 分享链接/二维码:V2Ray 不像 Shadowsocks 那样有统一规定的 URL 格式,所以各个 V2Ray 图形客户端的分享链接/二维码不一定通用。
  • 加密方式:V2Ray (特指 VMess 协议) 不像 Shadowsocks 那样看重对加密方式的选择,并且 VMess 的加密方式是由客户端指定的,服务器自适应。
  • 时间:使用 V2Ray 要保证时间准确,因为这是为了安全设计的。
  • 密码:V2Ray(VMesss) 只有 id(使用 UUID 的格式),作用类似于 Shadowsocks 的密码,但随机性远好于 Shadowsocks 的密码,只是不太方便记忆(安全和方便的矛盾)。
  • UDP 转发:VMess 是基于 TCP 的协议,对于 UDP 包 V2Ray 会转成 TCP 再传输的,即 UDP over TCP。要 UDP 转发功能在客户端的 socks 协议中开启 UDP 即可。
  • 路由器翻墙:实际上它们并没有什么区别,不要以为没有插件就不能在路由器上用,看事物请看本质。

v2ray-guide's People

Contributors

ariselia avatar biaocy avatar choutouketsu avatar claireis avatar darienraymond avatar evshiron avatar fankangsong avatar funray avatar gem7 avatar icarusradio avatar lack006 avatar lhuac avatar linpapa avatar machsix avatar miki-kagurazaka avatar minonl avatar myloft avatar newer027 avatar opportunityliu avatar pennz avatar ryanhui avatar stickh avatar sycct avatar toutyrater avatar unstartdev avatar victoriaraymond avatar wangnan789 avatar xianzhuo-sky avatar yaspee avatar yzqtdu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

v2ray-guide's Issues

V2Ray链式转发的补充教程

V2Ray中转(链式代理)教程
V2Ray的链式代理主要分为两大类:

  1. 通过服务端配置outbound到下一级服务端,并在每一级中转服务器上都做相应的配置,直到最终的翻墙服务器。
    链路逻辑如下:
    客户端 <-> 中转服务器1 <-> 中转服务器2 <-> 中转服务器3 ... <-> 中转服务器n <-> 翻墙服务器 <-> 目标网站

在此模型下,需要依次对每一台安装了V2ray的中转服务器端config.json进行修改,使得其outbound指向下一级中转服务器,中转服务器V2Ray的Protocol可以是shadowsocks或者Vmess(TCP,Websocket,MKCP,以及HTTP/2)。

举一个例子,“客户端 <-> 中转服务器1 <-> 翻墙服务器”,假设中转服务器1和翻墙服务器都采用WS+TLS+Caddy反代,中转服务器1和翻墙服务器都有真实的的域名和网页内容,下面是中转服务器1的服务端配置:
config.json
{
"inbound": {
"listen":"127.0.0.1",
"port": 443,
"protocol": "vmess",
"settings": {
"udp": true,
"clients": [
{
"id": "中转服务器1的用户UUID",
"alterId": 64
}
]
},
"streamSettings": {
"network":"ws",
"wsSettings":{
"path":"/ray01"//中转服务器1的path
}
}
},
"outbound" : {
"mux" : {
"concurrency" : 8,
"enabled" : true
},
"protocol" : "vmess",
"settings" : {
"vnext" : [
{
"users" : [
{
"id" : "翻墙服务器的用户UUID",
"alterId" : 64,
"security" : "auto"
}
],
"address" : "翻墙服务器的域名",
"port" : 443
}
]
},
"streamSettings" : {
"security" : "tls",
"wsSettings" : {
"headers" : {
"Host" : "翻墙服务器的域名"//注意,是翻墙服务器的域名
},
"path" : "ray02"//翻墙服务器的path
},
"network" : "ws",
"tlsSettings" : {
"allowInsecure" : false,
"serverName" : "翻墙服务器的域名"
}
}
},
"inboundDetour": [],
"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"
}
]
}
}
}
这样当客户端发送请求到中转服务器1的inbound,被中转服务器outbound到翻墙服务器去,形成了链式转发。上述例子中用的是WS+TLS,换成http/2也是成立的,但要把相应的配置都改成http/2的。
翻墙服务器的服务端配置不在此给出了,可以自行去查找相应的教程。
这种链式转发的优点是所有配置都在服务端,客户端看到的只是到中转服务器1的信息,适合机场管理员采用;但是缺点是要在中转服务器1里留下翻墙服务器的信息,如果中转服务器是国内vps提供商,存在被明文发现的隐患。

2.通过客户端配置,由客户端判定中转路径,直到最终到达翻墙服务器。
链路逻辑如下:
客户端 <-> 中转服务器1 <-> 中转服务器2 <-> 中转服务器3 ... <-> 中转服务器n <-> 翻墙服务器 <-> 目标网站
V2Ray本身自带Vmess TCP的链式转发。请参考官方教程的proxySettings{}函数。下面仅给出一个完整的客户端配置例子参考:
config.json
{
"inbound" : {
"port" : 8081,
"listen" : "127.0.0.1",
"protocol" : "http",
"settings" : {

}

},
"inboundDetour" : [
{
"domainOverride" : [
"http",
"tls"
],
"port" : 1080,
"listen" : "127.0.0.1",
"protocol" : "socks",
"settings" : {
"auth" : "noauth",
"udp" : true
}
}
],
"outbound" : {
"mux" : {
"concurrency" : 8,
"enabled" : true
},
"protocol" : "vmess",
"settings" : {
"vnext" : [
{
"users" : [
{
"id" : "翻墙服务器的用户UUID",
"alterId" : 64,
"security" : "auto"
}
],
"address" : "翻墙服务器的ip",
"port" : 443
}
]
},
"streamSettings" : {
"security" : "auto",
"tcpSettings" : {
"header" : {
"type" : "none"
}
},
"network" : "tcp",//这里一定是tcp,因为proxySettings函数仅支持tcp,如果是别的协议,要通过其他方法中转
"tlsSettings" : {
"allowInsecure" : true
}
},
"tag" : "proxy",//outboundTag是proxy,下面分流要用到
"proxySettings" : {
"tag" : "transit"//这个tag名字必须和下面的outboundDetour里的中转服务器的tag一致
}//这里调用proxySettings函数,白话翻译过来就是告诉客户端,要想访问outbound里设置的翻墙服务器,先去找proxySetting里定义的“transit”服务器,“transit”服务器是什么?在哪儿?去下面的outboundDetour找:)
},
"outboundDetour" : [
{
"protocol" : "blackhole",
"settings" : {

  },
  "tag" : "block"
},
{
  "protocol" : "freedom",
  "settings" : {

  },
  "tag" : "direct"
},
{
  "protocol" : "vmess",
  "settings" : {
    "vnext" : [
      {
        "users" : [
          {
            "id" : "中转服务器1的UUID",
            "alterId" : 64
          }
        ],
        "address" : "中转服务器1的ip地址",
        "port" : 443
      }
    ]
  },
  "tag": "transit"//中转服务器的outboundTag
}

],
"dns" : {
"servers" : [
"223.5.5.5",
"8.8.8.8"
]
},
"routing" : {
"settings" : {
"rules" : [
{
"type" : "field",
"domain" : [
"dropbox",
"github",
"google",
"instagram",
"tumblr",
"twitter",
"domain:facebook.com",
"domain:youtube.com",
"domain:google.com"
],//依照个人爱好添加删减
"outboundTag" : "proxy"
},
{
"type" : "field",
"ip" : [
"125.209.222.0/24",
"149.154.167.0/24",
"149.154.175.0/24",
"91.108.56.0/24"
],//telegram的服务器地址:)
"outboundTag" : "proxy"
},
{
"type" : "field",
"domain" : [
"geosite:cn"
],
"outboundTag" : "direct"
},
{
"type" : "field",
"ip" : [
"geoip:cn",
"geoip:private"
],
"outboundTag" : "direct"
},
{
"type" : "field",
"domain" : [
"domain:doubleclick.net"
],
"outboundTag" : "block"
}
],
"domainStrategy" : "AsIs"
},
"strategy" : "rules"
}
}
上述例子实现了“客户端 <-> 中转服务器1 <-> 翻墙服务器”的路径,但是要求翻墙服务器必须采用Vmess TCP,如果有多级转发,依次在outboundDetour里加入下一级的转发服务器信息,但记住,真正的翻墙服务器信息一定写在outbound里。

那么问题来了,对于翻墙服务器不是Vmess TCP协议的,该如何转发呢?这时候我们需要用到V2Ray的dokodemo-door协议。它支持shadowsocks, Vmess(websocket, http/2,kcp)的链式代理。
基本逻辑思路就是在客户端本机回环地址127.0.0.1建立一个dokodemo-door监听端口,将所有的客户端inbound(包括inboundDetour)收到的信息通过客户端outbound发送到这个任意门监听端口,由任意门再发往下一级中转服务器。
下面的例子是按照“客户端 <-> 中转服务器1 <-> 中转服务器2 <-> 翻墙服务器”的路径,其中翻墙服务器采用了WS+TLS+Caddy,中转服务器1和中转服务器2都是默认的V2Ray安装。
config.json
{
"inbound" : {
"domainOverride" : [
"http",
"tls"
],
"port" : 8081,
"listen" : "127.0.0.1",
"protocol" : "http",
"settings" : {
"allowTransparent" : true
}
},//主传入http
"outbound" : {
"mux" : {
"concurrency" : 8,
"enabled" : true
},
"protocol" : "vmess",
"settings" : {
"vnext" : [
{
"users" : [
{
"id" : "翻墙服务器的用户UUID",
"alterId" : 64,
"security" : "auto"
}
],
"address" : "127.0.0.1",//这里一定要填写本机回环地址,就是将翻墙服务器的用户UUID,alterID和加密方式要发送到dokodemo-door去
"port" : 50001//这个端口和下面的dokodemo-door监听端口保持一致
}
]
},
"streamSettings" : {
"security" : "tls",
"wsSettings" : {
"headers" : {
"Host" : "翻墙服务器的域名"
},
"path" : "/ray"
},
"network" : "ws",//本例子采用websocket+tls+caddy作为翻墙服务器的配置
"tlsSettings" : {
"allowInsecure" : false,
"serverName" : "翻墙服务器的域名"
}
},
"tag" : "proxy"
},
"inboundDetour" : [
{
"port" : 50001,//在端口50001建立一个任意门监听端口,和上面outbound的端口保持一致
"listen" : "127.0.0.1",//监听本机回环地址
"protocol" : "dokodemo-door",
"settings" : {
"port" : 443,//这个端口就不能乱改了,设为443是因为本教程所有的翻墙服务器都有真实的域名和真实的证书,有真实的网站伪装。
"network" : "tcp, udp",//同时监听tcp和udp
"address" : "翻墙服务器的域名"
},//在dokodemo-door里要定义真正的翻墙服务器的端口和地址,这里地址采用了域名。
"tag" : "bridge"//桥接tag,可以随意起名字,但和后面要保持一致
},
{
"port" : 1081,
"listen" : "127.0.0.1",
"protocol" : "socks",
"settings" : {
"auth" : "noauth",
"timeout" : 0,
"udp" : true
}
}//额外传入socks
],
"outboundDetour" : [
{
"protocol" : "vmess",
"settings" : {
"vnext" : [
{
"users" : [
{
"id" : "中转服务器1的用户UUID",
"alterId" : 64
}
],
"address" : "中转服务器1的ip地址",
"port" : 443
}
]
},
"tag" : "transit1"//中转服务器1的标识
},
{
"protocol" : "vmess",
"settings" : {
"vnext" : [
{
"users" : [
{
"id" : "中转服务器2的用户UUID",
"alterId" : 64
}
],
"address" : "中转服务器2的ip地址",
"port" : 443
}
]
},
"tag" : "transit2",//中转服务器2的标识
"proxySettings" : {
"tag" : "transit1"
}//对,这里要用到proxySettings函数,无论翻墙服务器采用哪种协议,中转服务器1、2...n之间用tcp协议传输;这里白话翻译过来就是:“要想访问transit2,先去找transit1中转”
},
{
"protocol" : "blackhole",
"settings" : {

  },
  "tag" : "block"
},
{
  "protocol" : "freedom",
  "settings" : {

  },
  "tag" : "direct"
}

],
"dns" : {
"servers" : [
"1.1.1.1",
"223.5.5.5",
"8.8.8.8",
"119.29.29.29",
"114.114.114.114"
]
},
"routing" : {
"settings" : {
"rules" : [
{
"type" : "field",
"inboundTag" : [
"bridge"
],//将inboundTag “bridge”绑定到outboundTag “transit2”上
"outboundTag" : "transit2"//将dokodemo-door监听到的信息发送给transit2服务器,这里一定是transit2,如果有n个转发服务器,这里一定是最后一个transitn
},//这是逻辑最绕的一部分。白话说就是 “客户端手上拿了个苹果交给主传入,主传入又把苹果交给主传出(本机回环127.0.0.1的50001端口),苹果在本机回环的50001端口被dokodemo-door抢走(监听)并要送给transit2,但是transit2说必须先把苹果先交给transit1(proxySettings的设置),由transit1把苹果给transit2....
{
"type" : "field",
"domain" : [
"dropbox",
"github",
"google",
"tumblr",
"twitter",
"domain:facebook.com",
"domain:youtube.com",
"domain:twitter.com"
],
"outboundTag" : "proxy"
},
{
"type" : "field",
"ip" : [
"125.209.222.0/24",
"149.154.167.0/24",
"149.154.175.0/24",
"91.108.56.0/24"
],
"outboundTag" : "proxy"
},
{
"type" : "field",
"domain" : [
"geosite:cn"
],
"outboundTag" : "direct"
},
{
"type" : "field",
"ip" : [
"geoip:cn",
"geoip:private"
],
"outboundTag" : "direct"
},
{
"type" : "field",
"ip" : [
"192.168.1.0/24",
"192.168.0.0/24"
],
"outboundTag" : "direct"
},
{
"type" : "field",
"domain" : [
"domain:doubleclick.net"
],
"outboundTag" : "block"
}
],
"domainStrategy" : "AsIs"
},
"strategy" : "rules"
}
}
下面再给出一个类似的例子,依旧实现“客户端 <-> 中转服务器1 <-> 中转服务器2 <-> 翻墙服务器”的路径,只不过翻墙服务器换成http/2的。
config.json
{
"log" : {
"access" : "",
"loglevel" : "none",
"error" : ""
},
"inboundDetour" : [
{
"port" : 50001,
"listen" : "127.0.0.1",
"protocol" : "dokodemo-door",
"settings" : {
"port" : 443,
"network" : "tcp,udp",
"address" : "翻墙服务器的域名"
},
"tag" : "bridge"
},
{
"port" : 1080,
"listen" : "127.0.0.1",
"protocol" : "socks",
"settings" : {
"auth" : "noauth",
"timeout" : 0,
"udp" : true
}
}
],
"outboundDetour" : [
{
"protocol" : "vmess",
"settings" : {
"vnext" : [
{
"users" : [
{
"id" : "中转服务器1的用户UUID",
"alterId" : 64
}
],
"address" : "中转服务器1的ip地址",
"port" : 443
}
]
},
"tag" : "transit1"
},
{
"protocol" : "vmess",
"settings" : {
"vnext" : [
{
"users" : [
{
"id" : "中转服务器2的用户UUID",
"alterId" : 64
}
],
"address" : "中转服务器2的ip地址",
"port" : 443
}
]
},
"tag" : "transi2",
"proxySettings" : {
"tag" : "transit1"
}

  • },

    {
    "protocol" : "freedom",
    "settings" : {

    },
    "tag" : "direct"
    

    },
    {
    "protocol" : "blackhole",
    "settings" : {

    },
    "tag" : "block"
    

    }
    ],
    "dns" : {
    "servers" : [
    "223.5.5.5",
    "8.8.8.8",
    "1.1.1.1",
    "119.29.29.29",
    "114.114.114.114"
    ]
    },
    "inbound" : {
    "port" : 8081,
    "listen" : "127.0.0.1",
    "protocol" : "http",
    "settings" : {
    "allowTransparent" : true,
    "timeout" : 360
    }
    },
    "outbound" : {
    "mux": {
    "concurrency": 8,
    "enabled": true
    },
    "protocol" : "vmess",
    "settings" : {
    "vnext" : [
    {
    "users" : [
    {
    "id" : "翻墙服务器的用户UUID",
    "alterId" : 64,
    "security": "auto"
    }
    ],
    "address" : "127.0.0.1",
    "port" : 50001
    }
    ]
    },
    "streamSettings" : {
    "security" : "tls",
    "httpSettings" : {
    "path" : "/rayhttp2",//翻墙服务器http2的path
    "host" : [
    "翻墙服务器的域名"
    ]
    },
    "network" : "h2",//http2
    "tlsSettings" : {
    "serverName" : "翻墙服务器的域名",
    "allowInsecure" : false
    }//这里一定要有tlsSettings,serverName要填写翻墙服务器的域名,否则http/2连不通
    },
    "tag" : "proxy"
    },
    "routing" : {
    "settings" : {
    "rules" : [
    {
    "type" : "field",
    "inboundTag" : [
    "bridge"
    ],
    "outboundTag" : "transit2"
    },
    {
    "type" : "field",
    "domain" : [
    "domain:doubleclick.net"
    ],
    "outboundTag" : "block"
    },
    {
    "type" : "field",
    "ip" : [
    "149.154.167.0/24",
    "149.154.175.0/24",
    "91.108.56.0/24",
    "125.209.222.0/24"
    ],
    "outboundTag" : "proxy"
    },
    {
    "type" : "field",
    "domain" : [
    "twitter",
    "domain:twimg.com",
    "domain:t.co",
    "google",
    "domain:xvideos.com"//:)
    ],
    "outboundTag" : "proxy"
    },
    {
    "type" : "field",
    "ip" : [
    "geoip:cn",
    "geoip:private"
    ],
    "outboundTag" : "direct"
    },
    {
    "type" : "field",
    "domain" : [
    "geosite:cn"
    ],
    "outboundTag" : "direct"
    }
    ],
    "domainStrategy" : "AsIs"
    },
    "strategy" : "rules"
    }
    }
    这类在客户端配置实现多级中转(链式代理)的优点在于一旦服务器安装好V2Ray就不需要再动服务器了,所有信息都在本地,除非你手机丢了,别人看不到你其他服务器的信息。一旦链路上任何一个服务器出现故障,可以随意丢弃,修改本地客户端的配置即可。
    小结:上面介绍了两大类V2Ray中转的思路。由于中转并不是大众需求,也不可能提供一键部署,还请各位自己对照着实践一下,有问题先尝试自己解决,实在解决不了到Project V的电报群里沟通。

Missing LICENSE

感谢作者编写的教程,但是项目没有许可协议,希望补充以明确允许的用途,比如 CC 或者其它许可。

WebSocket+TLS+caddy方案客户端一直报错

我之前的配置参考的是V2RAY配置指南中的TLS一章,使用没有问题。今天尝试使用WebSocket+TLS+caddy的方案客户端报错,服务器端无错误。客户端的报错内容:

2019/07/31 11:09:18 [Warning] [756935591] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ...:443: connectex: No connection could be made because the target machine actively refused it.] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:20 [Warning] [3688295484] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ...:443: connectex: No connection could be made because the target machine actively refused it.] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:20 [Warning] [1702724769] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ...:443: connectex: No connection could be made because the target machine actively refused it.] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:21 [Warning] [2863789953] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ...:443: connectex: No connection could be made because the target machine actively refused it.] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:24 [Warning] [991900366] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ...:443: connectex: No connection could be made because the target machine actively refused it.] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:30 [Warning] [2049262718] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [v2ray.com/core/transport/internet/websocket: failed to dial WebSocket > v2ray.com/core/transport/internet/websocket: failed to dial to (wss://www..****:10000/ray): > dial tcp ...:10000: connectex: No connection could be made because the target machine actively refused it. v2ray.com/core/transport/internet/websocket: failed to dial WebSocket > v2ray.com/core/transport/internet/websocket: failed to dial to (wss://www..****:10000/ray): > dial tcp ...:10000: operation was canceled v2ray.com/core/transport/internet/websocket: failed to dial WebSocket > v2ray.com/core/transport/internet/websocket: failed to dial to (wss://www..****:10000/ray): > dial tcp: operation was canceled] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:34 [Warning] [3762663331] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ...
:443: connectex: No connection could be made because the target machine actively refused it.] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:38 [Warning] [2124582238] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ..
.:443: connectex: No connection could be made because the target machine actively refused it. dial tcp ...:443: i/o timeout dial tcp ...:443: connectex: No connection could be made because the target machine actively refused it. dial tcp ...:443: operation was canceled] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:43 [Warning] [3992271906] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ..
.:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. dial tcp ...:443: connectex: No connection could be made because the target machine actively refused it. dial tcp ...:443: operation was canceled dial tcp: operation was canceled] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:43 [Warning] [1844546635] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ..
.:443: connectex: No connection could be made because the target machine actively refused it.] > v2ray.com/core/common/retry: all retry attempts failed
2019/07/31 11:09:48 [Warning] [1559604368] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [dial tcp ..
.*:443: connectex: No connection could be made because the target machine actively refused it.] > v2ray.com/core/common/retry: all retry attempts failed

1、服务器caddy配置:

www.*****.****
{
  log /var/log/caddy.log
  proxy /ray localhost:10000{
    websocket
    header_upstream -Origin
  }
}

2、服务器v2ray配置:

{
  "log": {
    "loglevel": "warning",
    "error": "/var/log/v2ray/error.log"
  },
  "inbounds": [
    {
      "port": 10000,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "uuid",
            "alterId": 64
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/ray"
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

3、客户端配置:

{
  "log": {
    "loglevel": "warning", 
    "access": "D:\\Downloads\\v2ray-windows-64\\doc\\access.log",  
    "error": "D:\\Downloads\\v2ray-windows-64\\doc\\error.log"
  },
  "inbounds": [
    {
      "port": 1080,
      "listen": "127.0.0.1",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "www.*****.****",
            "port": 443,
            "users": [
              {
                "id": "uuid",
                "alterId": 64
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "wsSettings": {
          "path": "/ray"
        }
      }
    }
  ]
}

Docker 部署 V2Ray的运行脚本错误

首先感谢作者的详尽文档,节省了我很多学习时间。昨天按照Docker部署V2Ray一节的指导进行操作,发现端口总是连不通,查了一天,发现是运行脚本的冒号有问题:
$ sudo docker run -d --name v2ray -v /etc/v2ray:/etc/v2ray -p 8888:8888 v2ray/official v2ray -config=/etc/v2ray/config.json

应为

$ sudo docker run -d --name v2ray -v /etc/v2ray:/etc/v2ray -p 8888:8888 v2ray/official v2ray -config=/etc/v2ray/config.json

望更正。

教程里多了个逗号

你好, 你的教程写的非常好特别感谢
不过,在最后那节 “域名文件” 最后一个代码的最后一行多了个逗号,就在"ext:h2y.dat:gfw"后面
如果有时间麻烦删除,以防其他人用了错了
谢谢

Nginx配置不通

服务器端配置文件:

{
  "inbounds": [{
    "port": 23220,
    "listen": "127.0.0.1",
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "593fc06a-50e2-49e2-8d32-ced22d6eba96",
          "alterId": 64
        }
      ]
    },
    "streamSettings": {
      "network": "ws",
      "waSettings": {
        "path": "/tower"
      }
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  }]
}

客户端配置文件:

{
  "log": {
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "port": 1080,
      "listen": "127.0.0.1",
      "tag": "socks-inbound",
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": false
      },
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "tokyo.makeafricagreatagain.work",
            "port": 443,
            "users": [
              {
                "id": "593fc06a-50e2-49e2-8d32-ced22d6eba96",
                "alterId": 64
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "wsSettings": {
          "path": "/tower"
        }
      },
      "tag": "direct"
    }
  ]
}

Nginx配置:

server {
        listen 443 ssl;
        listen [::]:443 ssl;

        server_name tokyo.makeafricagreatagain.work;

        ssl on;
        ssl_certificate /etc/letsencrypt/live/tokyo/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/tokyo/privkey.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!aNULL:!MD5;

        location /tower {
                proxy_redirect off;
                proxy_pass http://127.0.0.1:23220;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $http_host;

                # Show realip in v2ray access.log
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

客户端一直报错:

2019/06/04 22:30:11 tcp:127.0.0.1:9946 accepted tcp:ip138.com:80
2019/06/04 22:30:18 [Warning] [3621253216] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2  
ray.com/core/proxy/vmess/outbound: failed to find an available destination > v2ray.com/core/common/retry: [v2ray.com/cor  
e/transport/internet/websocket: failed to dial WebSocket > v2ray.com/core/transport/internet/websocket: failed to dial t  
o (wss://tokyo.makeafricagreatagain.work/tower): 404 Not Found > websocket: bad handshake] > v2ray.com/core/common/retry  
: all retry attempts failed

Nginx都是这样的错误:

106.61.100.68 - - [04/Jun/2019:14:30:18 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:24 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:25 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:26 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:27 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:28 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:29 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:33 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:37 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"
106.61.100.68 - - [04/Jun/2019:14:30:38 +0000] "GET /tower HTTP/1.1" 404 0 "-" "Go-http-client/1.1"

Nginx版本1.14.0。V2Ray服务器和客户端版本均为4.19.1。

请问这是什么问题?如何解决?

JSON配置中使用了全角标点

在这一节中:

https://toutyrater.github.io/basic/routing/cndirect.html#%E5%AE%A2%E6%88%B7%E7%AB%AF

如下的位置:

      {
        "type": "chinaip",
        "outboundTag": "direct",
        "ip": [
          "geoip:cn",// **大陆的 IP
          "geoip:private" // 私有地址 IP,如路由器等
        ]
      }

的这个逗号:

      {
        "type": "chinaip",
        "outboundTag": "direct",
        "ip": [
          "geoip:cn",// **大陆的 IP
                    ^
          "geoip:private" // 私有地址 IP,如路由器等
        ]
      }

使用了全角标点.

如果有人使用了TXT来编辑文件,估计这个问题能让他找好几个小时:joy:

CDN与本机IP?

大佬您好!我配置好了WebSocket+TLS+Web+CDN,科学上网没问题,电脑上也能查到v2ray连接的是CDN节点,只是还有点疑问。我通过浏览器查询本机IP时,应该显示CDN节点的IP,还是VPS的IP?目前显示的是VPS的IP,这与通过CDN能隐藏VPS的真实IP有矛盾吗?

关于一个nginx配置引起的报错

非常感谢:
https://toutyrater.github.io/advanced/wss_and_web.html
里的详细解释,不过我在配置的时候发现了一个错误,在客户端日志里,有类似下面的错误:
failed to dial to (wss://xxx/yyy/): 400 Bad Request: too many Host headers
经研究发现,可能跟这个问题有关:
https://stackoverflow.com/questions/38146781/how-to-set-up-nginx-as-reverse-proxy-bastion-i-have-400bad-request-too-many
然后我在您的示例nginx配置里看到:
proxy_set_header Host $http_host;
proxy_set_header Host $host;
确实有两个Header,我注释掉一个之后,问题解决了。是不是可以在文档里说明一下?或者把这个tip加入到常见问题里?

教程里alterid的问题

教程里写的是:

"alterId": 64 // 此处的值也应当与服务器相同

配置中的 alterId 也是作为认证的,具体请看 V2Ray 用户手册。只要确保服务器和客户端配置文件的 alterId 相同就行了,但要注意 alterId 的值越大会使用 V2Ray 占用更多的内存。根据我的经验,对于一般用户来说,alterId 的值设为 30 到 100 之间应该是比较合适的。

目前 alterId 服务器和客户端不一致的情况下也有可能正常连接,这不是 BUG,但还是建议保持一致。

官方文档的说法是:

alterId:为了进一步防止被探测,一个用户可以在主 ID 的基础上,再额外生成多个 ID。这里只需要指定额外的 ID 的数量,推荐值为 32。不指定的话,默认值是 0。最大值 65535。这个值不能超过服务器端所指定的值。

我自己实测是客户端alterid低于服务器是可以正常使用的。个人理解是服务器alterid的设计是为了防止客户端值过大导致服务器内存崩溃。而小内存的客户端设备(路由器等)可以视情况调低alterid减少内存使用。

See also:
v2ray/v2ray-core#92

请教能否实现服务端中转SSR?

非常感谢通俗教程。
不知作者有无考虑过实现中转ssr呢?官方说是不支持ssr, 但到了现在ssr于各大机场中都还是很普遍。于是想尝试一下有无可能用v2中转。
初步尝试过outbounds中添加ssr的socks出口路由,但填入protocol:socks后会报错,不填protocol的话虽不报错但无法联通。本地socks地址验证过可用性。
请问作者觉得中转有可能实现吗?

反向代理2: error 2ray.com/core/app/reverse: failed to process reverse connection > v2ray.com/core/app/reverse: empty worker list

我按照教程设置了反向代理2的两个模板, B节点error.log 显示

 v2ray.com/core/app/dispatcher: taking detour [portal] for [tcp:www.gstatic.com:80]
2019/01/09 23:23:04 [Info] [2064198378] v2ray.com/core/app/reverse: failed to process reverse connection > v2ray.com/core/app/reverse: empty worker list

access.log 显示

2019/01/09 23:31:07 [2408:84f4:44:9870:885d:cdc2:4a6:69db]:40392 accepted tcp:www.gstatic.com:80

A 的配置文件

{
  "reverse":{

    "bridges":[
      {
        "tag":"bridge",
        "domain":"private.cloud.com"
      }
    ]
  },
  "outbounds":[
    {
      "protocol":"freedom",
      "settings":{
      },
      "tag":"out"
    },
    {

    "tag":"tunnel",
    "protocol":"vmess",
    "settings":{
      "vnext":[
        {
          "address":"xxx.com",
          "port":9999,
          "users":[
            {
              "id":"b831381d-6324-4d53-ad4f-8cda48b30811",
              "alterId":64
            }
          ]
        }
      ]
    }
  }
  ],
  "routing":{
    "strategy":"rules",
    "settings":{
      "rules":[
        {
          "type":"field",
          "inboundTag":[
            "bridge"
          ],
          "domain":[
            "full:private.cloud.com"
          ],
          "outboundTag":"tunnel"
        },
        {
          "type":"field",
          "inboundTag":[
            "bridge"
          ],
          "outboundTag":"out"
        }
      ]
    }
  }
}

B的配置文件

{
	"api": {
		"services": [
			"HandlerService",
			"LoggerService",
			"StatsService"
		],
		"tag": "api"
	},
	"inbounds": [{
			"listen": "127.0.0.1",
			"port": 2333,
			"protocol": "dokodemo-door",
			"settings": {
				"address": "127.0.0.1"
			},
			"tag": "api"
		},
{
			"tag": "MAIN_INBOUND",
			"port": 10000,
			"protocol": "vmess",
			"settings": {
				"clients": [{
					"id": "b866666d-6324-4d53-ad4f-8cda48b30811",
					"alterId": 64
				}]
			}
		},
		{
			"tag": "tunnel",
			"port": 9999,
			"protocol": "vmess",
			"settings": {
				"clients": [{
					"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
					"alterId": 64
				}]
			}
		}
	],
	"log": {
		"access": "/var/log/v2ray/access.log",
		"error": "/var/log/v2ray/error.log",
		"loglevel": "info"
	},
	"outbounds": [{
			"protocol": "freedom",
			"settings": {}
		},
		{
			"protocol": "blackhole",
			"settings": {},
			"tag": "blocked"
		}
	],
	"policy": {
		"levels": {
			"0": {
				"bufferSize": 10240,
				"connIdle": 300,
				"downlinkOnly": 5,
				"handshake": 4,
				"statsUserDownlink": true,
				"statsUserUplink": true,
				"uplinkOnly": 2
			}
		},
		"system": {
			"statsInboundDownlink": false,
			"statsInboundUplink": false
		}
	},
"reverse":{
    "portals":[
      {
        "tag":"portal",
        "domain":"private.cloud.com"
      }
    ]
  },
	"routing": {
		"settings": {
			"rules": [{
					"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",
					"protocol": [
						"bittorrent"
					],
					"type": "field"
				},
				{
					"inboundTag": [
						"api"
					],
					"outboundTag": "api",
					"type": "field"
				},
				{
					"domain": [
						"regexp:(api|ps|sv|offnavi|newvector|ulog\\.imap|newloc)(\\.map|)\\.(baidu|n\\.shifen)\\.com",
						"regexp:(.+\\.|^)(360|so)\\.(cn|com)",
						"regexp:(.?)(xunlei|sandai|Thunder|XLLiveUD)(.)"
					],
					"outboundTag": "blocked",
					"type": "field"
				},
				{
					"type": "field",
					"inboundTag": [
						"MAIN_INBOUND"
					],
					"outboundTag": "portal"
				},
				{
					"type": "field",
					"inboundTag": [
						"tunnel"
					],
					"domain": [
						"full:private.cloud.com"
					],
					"outboundTag": "portal"
				}
			]
		},
		"strategy": "rules"
	},
	"stats": {}
}

希望能帮忙看看那 谢谢

透明代理问题

如果我用虚拟机做网关,当我把虚拟机关了的时候,那不就家里设备都无法上网了??

suggestion

关于透明代理介绍 UDP部分您可以参考一下这里

{
"domainOverride": ["tls", "http"],
"listen": "0.0.0.0",
"port": 12345,
"protocol": "dokodemo-door",
"settings": {
"followRedirect": true
},
"streamSettings": {
"sockopt": {
"mark": 100,
"tcpFastOpen": false,
"tproxy": "tproxy"
}
}
},

https://www.sumju.net/?p=241

路由配置策略与outbounds配置顺序需要搭配

首先谢谢大佬的教程!
然后下面是遇到的一个问题及解决方法,希望对其他人有点用。

https://toutyrater.github.io/routing/sitedata.html#外置的域名文件 配置路由时,rules段如下,
"rules":[
{
"type": "field",
"outboundTag": "proxy",
"domain": [
"ext:h2y.dat:gfw"
]
}
]

但国内网站还是走代理,后来发现,在https://toutyrater.github.io/basic/routing/cndirect.html#说明 里有一句,

这因为 outbounds 中的第一个出口协议是作为默认的出口,当一个数据包没有匹配的规则时,路由就会把数据包发往默认出口

于是把outbounds里面的direct配置放到第一个去,这样就行了,如下,
"outbounds": [
{
"tag": "direct",
"protocol": "freedom",
"settings": {
"vnext": null,
"servers": null,
"response": null
},
"streamSettings": null,
"mux": null
},
{
"tag": "proxy",
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "...................",
"port": ...........,
"users": [
{
"id": "........................",
"alterId": 16,
"security": "aes-128-gcm"
}
]
}
],
"servers": null,
"response": null
},
"streamSettings": {
"network": "tcp",
"security": "",
"tlsSettings": null,
"tcpSettings": null,
"kcpSettings": null,
"wsSettings": null,
"httpSettings": null
},
"mux": {
"enabled": true
}
},
{
"tag": "block",
"protocol": "blackhole",
"settings": {
"vnext": null,
"servers": null,
"response": {
"type": "http"
}
},
"streamSettings": null,
"mux": null
}
]

outbounds里面的第一个配置一般默认都是走代理的,但是路由配置成被 gfw 屏蔽的域名走代理后,国内域名因为不会匹配到这一条规则,就会直接按默认的第一个配置走代理,把direct放到第一个之后,国内域名就会直连了。相应的,如果路由配置成国内直连,那outbounds里面的第一个配置就要是走代理的。

作者后续更新的话,希望可以在路由配置里稍微提一下,路由配置策略与outbounds配置顺序需要搭配。

使用acme.sh通过standalone方式安装证书后续更新问题

教程中使用acme.sh通过--standalone方式安装证书,后续更新依然需要使用80端口,如果使用nignx会占用80端口,这样会导致无法自动更新证书,是不是应该采用其它模式(如Webroot 模式)安装证书更好一点,这样可以完成自动更新操作,或者有什么更好的办法吗?

强烈建议修补透明代理iptables规则

首先,感谢您的tproxy透明代理方案,算是我见过的唯一齐全的tproxy透明代理配置

然而,有关tproxy透明代理的iptables规则,建议添加:

iptables -t mangle -I V2RAY -d 255.255.255.255 -j RETURN

否则,网关路由器会出错,甚至整个局域网不稳定

折腾了我好一阵子

路由器透明代理无法上国内网站的问题

我使用的是华硕的 AC68U 路由器,原版梅林 (asuswrt) 固件,按照教程配置透明代理之后,访问墙外网站没问题,国内网站全部 timeout。
配置文件如下:

客户端:

{
  "log": {
    "loglevel": "warning",
    "access": "/tmp/v2ray/access.log",
    "error": "/tmp/v2ray/error.log"
  },
  "inbound": {
    "port": 1080,
    "protocol": "socks",
    "domainOverride": [
      "tls",
      "http"
    ],
    "settings": {
      "auth": "noauth",
      "udp": true
    }
  },
  "outbound": {
    "protocol": "vmess",
    "settings": {
      "vnext": [
        {
          "address": "server_ip",
          "port": 443,
          "users": [
            {
              "id": "id",
              "alterId": 64
            }
          ]
        }
      ],
      "mux": {
        "enable": true
      }
    },
    "streamSettings": {
      "network": "mkcp",
      "kcpSettings": {
        "mtu": 1350,
        "tti": 20,
        "uplinkCapacity": 5,
        "downlinkCapacity": 100,
        "congestion": false,
        "readBufferSize": 1,
        "writeBufferSize": 1,
        "header": {
          "type": "none"
        }
      }
    }
  },
  "inboundDetour": [
    {
      "domainOverride": [
        "tls",
        "http"
      ],
      "port": 12345,
      "protocol": "dokodemo-door",
      "settings": {
        "network": "tcp,udp",
        "followRedirect": true
      }
    }
  ],
  "outboundDetour": [
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    }
  ],
  "dns": {
    "servers": [
      "101.6.6.6",
      "202.141.162.123",
      "202.141.178.13",
      "223.113.97.99",
      "40.73.101.101"
    ]
  },
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPIfNonMatch",
      "rules": [
        {
          "type": "field",
          "port": 53,
          "network": "udp",
          "outboundTag": "direct"
        },
        {
          "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",
            "100.100.100.100/32",
            "188.188.188.188/32",
            "110.110.110.110/32",
            "104.160.185.171/32",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "direct"
        },
        {
          "type": "chinasites",
          "outboundTag": "direct"
        },
        {
          "type": "chinaip",
          "outboundTag": "direct"
        }
      ]
    }
  }
}

服务器:

{
  "log": {
    "loglevel": "warning",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },
  "inbound": {
    "sniffing": {
      "enabled": true,
      "destOverride": [
        "http",
        "tls"
      ]
    },
    "port": 443,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "id",
          "alterId": 64
        }
      ]
    },
    "streamSettings": {
      "network": "mkcp",
      "kcpSettings": {
        "mtu": 1350,
        "tti": 20,
        "uplinkCapacity": 5,
        "downlinkCapacity": 100,
        "congestion": false,
        "readBufferSize": 1,
        "writeBufferSize": 1,
        "header": {
          "type": "none"
        }
      }
    }
  },
  "outbound": {
    "protocol": "freedom",
    "settings": {}
  },
  "outboundDetour": [
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "block"
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "AsIs",
      "rules": [
        {
          "domain": [
            "domain:somewebsite",
          ],
          "type": "field",
          "outboundTag": "block",
          "protocol": [
            "http",
            "tls"
          ]
        },
        {
          "type": "field",
          "outboundTag": "block",
          "protocol": [
            "bittorrent"
          ]
        }
      ]
    }
  }
}

而且仍然可以访问被 blackhole 屏蔽的网站以及下载 BT。

Merlin 启动脚本 /jffs/scripts/post-mount

#!/bin/sh

if [ "$1" = "/tmp/mnt/sda1" ] ; then
  ln -nsf $1/entware /tmp/opt
fi

# Make and use the swapfile
swapon /tmp/mnt/sda1/swapfile
# V2Ray log folder
mkdir /tmp/v2ray
# Start V2Ray
/tmp/mnt/sda1/v2ray/v2ray &
# KoolProxy
/tmp/mnt/sda1/koolproxy/koolproxy -d --ipv6
# Update iprables rules
iptables -t nat -N V2RAY
iptables -t nat -A V2RAY -d 192.168.0.0/16 -j RETURN
iptables -t nat -A V2RAY -p tcp -j REDIRECT --to-ports 12345
iptables -t nat -A PREROUTING -p tcp -j V2RAY
ip rule add fwmark 1 table 100
ip route add local 0.0.0.0/0 dev lo table 100
iptables -t mangle -N V2RAY_MASK
iptables -t mangle -A V2RAY_MASK  -d 192.168.0.0/16 -j RETURN
iptables -t mangle -A V2RAY_MASK -p udp -j TPROXY --on-port 12345 --tproxy-mark 1
iptables -t mangle -A PREROUTING -p udp -j V2RAY_MASK
iptables -t nat -A OUTPUT -p tcp -j V2RAY
iptables -t nat -A V2RAY -d 0.0.0.0/8 -j RETURN
iptables -t nat -A V2RAY -d 10.0.0.0/8 -j RETURN
iptables -t nat -A V2RAY -d 127.0.0.0/8 -j RETURN
iptables -t nat -A V2RAY -d 169.254.0.0/16 -j RETURN
iptables -t nat -A V2RAY -d 172.16.0.0/12 -j RETURN
iptables -t nat -A V2RAY -d 192.168.0.0/16 -j RETURN
iptables -t nat -A V2RAY -d 224.0.0.0/4 -j RETURN
iptables -t nat -A V2RAY -d 240.0.0.0/4 -j RETURN
iptables -t nat -A V2RAY -m set --match-set chnroute dst -j RETURN
iptables -t nat -A V2RAY -p tcp -j REDIRECT --to-ports 1060
iptables -t nat -A PREROUTING -p tcp -j V2RAY
exit 0

请教一下到底是哪里配置有问题?

有试过在centos上安装嘛

在cnetos上配置不起来,v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/socks: connection ends > context canceled
报这个错误

部署了v2ray之后服务器上的wp博客无法访问了

你好,我在我的vultr vps上部署了v2ray之后,vps上的WordPress博客无法正常访问了,只能翻强才能访问,但是ip可以ping通,xshell也可以ssh连上服务器,感觉不是ip被强的问题,请问是不是我哪里没有设置好导致是这个问题,有没有什么办法解决?

DNS section

Hi
DNS section of the book is missing.
i am using v2ray with vmess protocol following all the official guides.but there is DNS leak issue.
when i visit dnsleaktest.com , DNS of my ISP is shown instead of my VPS.
is there any solution for this?
is this a problem of v2ray or i am missing something in the configuration?

高级篇中CDN部分也许可以更清晰

正好 V2Ray 已经支持 HTTP/2 了,又拍云、七牛、阿里都不错,腾讯的 h2 还在内测,百度不清楚。 这段话混淆了一个概念,目前国内CDN支持H2都指的是支持H2连接(从客户端到CDN服务器),但默认回源(从CDN服务器到目标服务器)都还是http/1.1。所以按照教程里说的配置h2 + tls + web + CDN是走不通的,而网上对这方面的解释很少。
希望能添加一段对CDN连接/回源的解释,或者之后我提交个Pull Request也行。

请问v2ray 内核版 如何让终端走代理

用的是终端启动的v2ray 设置了export ALL_PROXY=socks5://127.0.0.1:1080 / 终端还是ping 不通 google
用ss客户端这个方法是可行的 具体原理不是很懂 想让终端也走一下代理 想请教一下

怎么在自己的笔记本上做tproxy透明代理

你好我想在自己的笔记本上设置透明代理而不通过更改网关,我按照tproxy的去设置,发现dns不能解析,53端口的指向了192.168.x.1:53。ip能ping通,请问我应该怎么修改。

V2ray透明代理主机上部署docker,容器无法访问网络的问题

由于此教程里用v2ray实现透明代理的配置是我遇到过的最全面最详细的,所以在此再发一个issue。

大家都知道docker非常流行且实用,在运行v2ray透明代理的linux主机上部署几个docker愿望是不可避免的。
然而,实现起来却困难重重。

我相信其他人也遇到过这种情况,问题表现在:

透明代理正常运行,局域网里的设备可访问docker容器,但是docker容器无法访问外网。

我是在用docker部署RSSHub时遇到此问题。
我觉得问题出在
ip route add local 0.0.0.0/0 dev lo table 100

iptables的V2RAY_MASK链上,

docker使用172.17.0.0/24,貌似会在loop里死循环。

一个解决DNS污染并隐藏DNS查询(对于国内DNS服务商和GFW)

大佬您好,对于V2ray的第一次搭建,就是看着您的教程做的。这又经过几天的折腾,终于把网关透明代理搭建好了。其过程对于我这种半瓶水,就不说了,一把心酸泪啊,但是建成那一刻,太开心了。(路由器刷LEDE 17,做网关设备的是树莓派3B)
在您的透明代理教程里,说DNS查询可能会被国内DNS或GFW知道。这又经过几天折腾,找到一种解决办法,我自个测试着可以。但是水平有限,不知道是否存在哪些问题,还请大佬您看一下,看是否可行。
Fork了您的教程,修改在这个地方。
https://github.com/MassSmith/v2ray-guide/blob/master/app/transparent_proxy.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.