V2ray-core: 关于代理新模式

Created on 30 Apr 2020  ·  11Comments  ·  Source: v2ray/v2ray-core

V2Ray目前提供了代理转发的功能,中转服务器只能看到加密的数据,只要出口服务器安全可控数据安全就有保障,但还有个问题,就是这里的中转服务器只能指定一个,如果崩了或者被墙了就无法联网,我想弄一个多层转发,也就是可以指定N个中转服务器,软件自动切换最佳路线,目的服务器是同一个,这个属于比较大型的功能,希望能和各位开发者讨论讨论。目前已经有部分代理软件有这个功能,比如https://github.com/geph-official/geph2 开发者做了TCP连接快速恢复功能,连接中断自动建立新连接并重传未发送成功的数据等等

Stale

Most helpful comment

haproxy原理上可以做到,但是实现起来太麻烦了,有点杀鸡用牛刀的感觉。举一个例子,假如有一个机场给一个区域(例如hk)提供了5条线路,但有时候有线路会维护。

原本的config为:
client -> inbound -> routing (geoip:hk) -> balancer -> 5 outbounds

但只要有线路维护,这个balancer就会有访问问题,这时候得人手remove balancer里面的outbound,去掉不可用的。

如果用 haproxy,则config为:
client -> inbound -> routing (geoip:hk) -> haproxy socks outbound
5 * internal socks inbound -> routing (inbound: in-tag-1 -> outbound: out-tag-1) -> outbound
haproxy config为 haproxy socks inbound -> healthcheck rule -> 5 * internal socks inbound
相当于对每条线路,都要额外新增一个internal socks inbound (接受haproxy流量),以及一个routing rule。并且引入了额外的工具haproxy。

如果v2ray能加入简单的balancer health check,就能保留原来简单的配置,只需在balancer里面这样配置(example only),就可以达到同样的效果。

      {
        "tag": "out-hk-balancer",
        "selector": [
          "out-hk-1",
          "out-hk-2",
          "out-hk-3",
          "out-hk-4",
          "out-hk-5"
        ],
        "healthCheck": {
          "type": "http"|"tcp"|"icmp",
          "target": "https://cp.cloudflare.com"
        }
      },

All 11 comments

中转可以用balancer,这里的问题是balancer目前并不能支持节点测试和禁用,所有balancer里的节点都一定会访问。

为什么不考虑haproxy这样的东西

haproxy原理上可以做到,但是实现起来太麻烦了,有点杀鸡用牛刀的感觉。举一个例子,假如有一个机场给一个区域(例如hk)提供了5条线路,但有时候有线路会维护。

原本的config为:
client -> inbound -> routing (geoip:hk) -> balancer -> 5 outbounds

但只要有线路维护,这个balancer就会有访问问题,这时候得人手remove balancer里面的outbound,去掉不可用的。

如果用 haproxy,则config为:
client -> inbound -> routing (geoip:hk) -> haproxy socks outbound
5 * internal socks inbound -> routing (inbound: in-tag-1 -> outbound: out-tag-1) -> outbound
haproxy config为 haproxy socks inbound -> healthcheck rule -> 5 * internal socks inbound
相当于对每条线路,都要额外新增一个internal socks inbound (接受haproxy流量),以及一个routing rule。并且引入了额外的工具haproxy。

如果v2ray能加入简单的balancer health check,就能保留原来简单的配置,只需在balancer里面这样配置(example only),就可以达到同样的效果。

      {
        "tag": "out-hk-balancer",
        "selector": [
          "out-hk-1",
          "out-hk-2",
          "out-hk-3",
          "out-hk-4",
          "out-hk-5"
        ],
        "healthCheck": {
          "type": "http"|"tcp"|"icmp",
          "target": "https://cp.cloudflare.com"
        }
      },

今天试了一下haproxy的方式,发现不可行。haproxy不能用backend server作为proxy来发送http来测试backend server是否运行。。。所以没法用v2ray inbound 作为 haproxy backend...

今天试了一下haproxy的方式,发现不可行。haproxy不能用backend server作为proxy来发送http来测试backend server是否运行。。。所以没法用v2ray inbound 作为 haproxy backend...

可以做,开一个dokodemo-door的入站,haproxy的check写一个http协议的google.com/generate_204,check port写这个入站端口,检查回传是否是204即可

http check写法参见https://blog.yuanbin.me/posts/2018-06/2018-06-30_21-26-14/#http-check

check port写在server那行

http check写法参见https://blog.yuanbin.me/posts/2018-06/2018-06-30_21-26-14/#http-check

check port写在server那行

谢谢。我这两天在尝试这种方法,最终用tcp-check搞定。不过配置还是很复杂的,特别是涉及到中转。

我现在是拿clash 做负载的后端...v2ray 需要代理的数据通过socks发给clash, 然后clash 只做负载均衡 去连服务器...(主要是需要监听多个端口, 还要用v2ray做个vmess的前置代理, 所以只能v2ray+clash一起用了).

要是能在v2ray里面直接实现了就方便了..

mark

nginx反向代理不就完了,那么好用

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days

Was this page helpful?
0 / 5 - 0 ratings