v2ray / v2ray-core

A platform for building proxies to bypass network restrictions.
https://www.v2ray.com/
MIT License
45.19k stars 8.94k forks source link

HTTP/2+TLS+caddy v2无法使用,v2ray服务器日志提示:v2ray.com/core/app/proxyman/inbound: connection ends > /vmess/inbound: invalid request from xxx.xxx.xxx.xxx:34947 > /vmess/encoding: failed to drain connection DrainSize = 857 57 53 > /vmess/encoding: invalid user > /vmess: Not Found #2680

Closed CCBP closed 4 years ago

CCBP commented 4 years ago

除非特殊情况,请完整填写所有问题。不按模板发的 issue 将直接被关闭。 如果你遇到的问题不是 V2Ray 的 bug,比如你不清楚要如何配置,请使用Discussion进行讨论。

1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明) 4.27.0,服务器与客户端相同。 2) 你的使用场景是什么?比如使用 Chrome 通过 Socks/VMess 代理观看 YouTube 视频。 使用Chrome通过VMess代理使用Google搜索引擎等 3) 你看到的不正常的现象是什么?(请描述具体现象,比如访问超时,TLS 证书错误等) 无法代理,服务器日志显示:

v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from 112.101.248.33:34947 > v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 53 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found

我注意到#535#2554与我的问题类似,其中有人提到客户端与服务器端时间不同步的问题,因为我客户端windows时间同步的服务器为 time.windows.com,所以我在服务器端使用 ntpdate -u time.windows.com 同步时间后仍无法解决问题。 4) 你期待看到的正确表现是怎样的? 正常代理。 5) 请附上你的配置(提交 Issue 前请隐藏服务器端IP地址)。

服务器端配置:

{
  "log": {
    "loglevel": "debug",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },
  "inbounds": [{
    "port": 21059,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "my uuid",
          "level": 1,
          "alterId": 64
        }
      ]
    },
    "streamSetting": {
      "network": "h2",
      "security": "tls",
      "httpSettings": {
        "path": "/v2",
        "host": [
          "domain.me"
        ]
      },
      "tlsSettings": {
        "serverName": "domain.me",
        "certificates": [
          {
            "certificateFile": "/etc/caddy/domain_me.crt",
            "keyFile": "/etc/caddy/domain_me.key"
          }
        ]
      },
      "listen": "127.0.0.1"
    },
    "tag": "",
    "sniffing": {
      "enabled": true,
      "destOverride": [
        "http",
        "tls"
      ]
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}

客户端配置: 我使用v2rayN作为客户端,配置文件也是v2rayN生成的。

{
  "policy": {
    "system": {
      "statsInboundUplink": true,
      "statsInboundDownlink": true
    }
  },
  "log": {
    "access": "",
    "error": "",
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "tag": "proxy",
      "port": 2080,
      "listen": "0.0.0.0",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "settings": {
        "auth": "noauth",
        "udp": true,
        "ip": null,
        "address": null,
        "clients": null,
        "decryption": null
      },
      "streamSettings": null
    },
    {
      "tag": "api",
      "port": 1273,
      "listen": "127.0.0.1",
      "protocol": "dokodemo-door",
      "sniffing": null,
      "settings": {
        "auth": null,
        "udp": false,
        "ip": null,
        "address": "127.0.0.1",
        "clients": null,
        "decryption": null
      },
      "streamSettings": null
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "domain.me",
            "port": 21059,
            "users": [
              {
                "id": "my uuid",
                "alterId": 64,
                "email": "t@t.tt",
                "security": "auto",
                "encryption": null
              }
            ]
          }
        ],
        "servers": null,
        "response": null
      },
      "streamSettings": {
        "network": "h2",
        "security": "tls",
        "tlsSettings": {
          "allowInsecure": true,
          "serverName": "domain.me"
        },
        "tcpSettings": null,
        "kcpSettings": null,
        "wsSettings": null,
        "httpSettings": {
          "path": "/v2",
          "host": [
            "domain.me"
          ]
        },
        "quicSettings": null
      },
      "mux": {
        "enabled": true,
        "concurrency": 8
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {
        "vnext": null,
        "servers": null,
        "response": null
      },
      "streamSettings": null,
      "mux": null
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {
        "vnext": null,
        "servers": null,
        "response": {
          "type": "http"
        }
      },
      "streamSettings": null,
      "mux": null
    }
  ],
  "stats": {},
  "api": {
    "tag": "api",
    "services": [
      "StatsService"
    ]
  },
  "dns": null,
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "port": null,
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "ip": null,
        "domain": null
      },
      {
        "type": "field",
        "port": null,
        "inboundTag": null,
        "outboundTag": "proxy",
        "ip": null,
        "domain": [
          "geosite:google",
          "geosite:github",
          "geosite:netflix",
          "geosite:steam",
          "geosite:telegram",
          "geosite:tumblr",
          "geosite:speedtest",
          "geosite:bbc",
          "domain:gvt1.com",
          "domain:textnow.com",
          "domain:twitch.tv",
          "domain:wikileaks.org",
          "domain:naver.com"
        ]
      },
      {
        "type": "field",
        "port": null,
        "inboundTag": null,
        "outboundTag": "proxy",
        "ip": [
          "91.108.4.0/22",
          "91.108.8.0/22",
          "91.108.12.0/22",
          "91.108.20.0/22",
          "91.108.36.0/23",
          "91.108.38.0/23",
          "91.108.56.0/22",
          "149.154.160.0/20",
          "149.154.164.0/22",
          "149.154.172.0/22",
          "74.125.0.0/16",
          "173.194.0.0/16",
          "172.217.0.0/16",
          "216.58.200.0/24",
          "216.58.220.0/24",
          "91.108.56.116",
          "91.108.56.0/24",
          "109.239.140.0/24",
          "149.154.167.0/24",
          "149.154.175.0/24"
        ],
        "domain": null
      },
      {
        "type": "field",
        "port": null,
        "inboundTag": null,
        "outboundTag": "direct",
        "ip": null,
        "domain": [
          "domain:12306.com",
          "domain:51ym.me",
          "domain:52pojie.cn",
          "domain:8686c.com",
          "domain:abercrombie.com",
          "domain:adobesc.com",
          "domain:air-matters.com",
          "domain:air-matters.io",
          "domain:airtable.com",
          "domain:akadns.net",
          "domain:apache.org",
          "domain:api.crisp.chat",
          "domain:api.termius.com",
          "domain:appshike.com",
          "domain:appstore.com",
          "domain:aweme.snssdk.com",
          "domain:bababian.com",
          "domain:battle.net",
          "domain:beatsbydre.com",
          "domain:bet365.com",
          "domain:bilibili.cn",
          "domain:ccgslb.com",
          "domain:ccgslb.net",
          "domain:chunbo.com",
          "domain:chunboimg.com",
          "domain:clashroyaleapp.com",
          "domain:cloudsigma.com",
          "domain:cloudxns.net",
          "domain:cmfu.com",
          "domain:culturedcode.com",
          "domain:dct-cloud.com",
          "domain:didialift.com",
          "domain:douyutv.com",
          "domain:duokan.com",
          "domain:dytt8.net",
          "domain:easou.com",
          "domain:ecitic.net",
          "domain:eclipse.org",
          "domain:eudic.net",
          "domain:ewqcxz.com",
          "domain:fir.im",
          "domain:frdic.com",
          "domain:fresh-ideas.cc",
          "domain:godic.net",
          "domain:goodread.com",
          "domain:haibian.com",
          "domain:hdslb.net",
          "domain:hollisterco.com",
          "domain:hongxiu.com",
          "domain:hxcdn.net",
          "domain:images.unsplash.com",
          "domain:img4me.com",
          "domain:ipify.org",
          "domain:ixdzs.com",
          "domain:jd.hk",
          "domain:jianshuapi.com",
          "domain:jomodns.com",
          "domain:jsboxbbs.com",
          "domain:knewone.com",
          "domain:kuaidi100.com",
          "domain:lemicp.com",
          "domain:letvcloud.com",
          "domain:lizhi.io",
          "domain:localizecdn.com",
          "domain:lucifr.com",
          "domain:luoo.net",
          "domain:mai.tn",
          "domain:maven.org",
          "domain:miwifi.com",
          "domain:moji.com",
          "domain:moke.com",
          "domain:mtalk.google.com",
          "domain:mxhichina.com",
          "domain:myqcloud.com",
          "domain:myunlu.com",
          "domain:netease.com",
          "domain:nfoservers.com",
          "domain:nssurge.com",
          "domain:nuomi.com",
          "domain:ourdvs.com",
          "domain:overcast.fm",
          "domain:paypal.com",
          "domain:paypalobjects.com",
          "domain:pgyer.com",
          "domain:qdaily.com",
          "domain:qdmm.com",
          "domain:qin.io",
          "domain:qingmang.me",
          "domain:qingmang.mobi",
          "domain:qqurl.com",
          "domain:rarbg.to",
          "domain:rrmj.tv",
          "domain:ruguoapp.com",
          "domain:sm.ms",
          "domain:snwx.com",
          "domain:soku.com",
          "domain:startssl.com",
          "domain:store.steampowered.com",
          "domain:symcd.com",
          "domain:teamviewer.com",
          "domain:tmzvps.com",
          "domain:trello.com",
          "domain:trellocdn.com",
          "domain:ttmeiju.com",
          "domain:udache.com",
          "domain:uxengine.net",
          "domain:weather.bjango.com",
          "domain:weather.com",
          "domain:webqxs.com",
          "domain:weico.cc",
          "domain:wenku8.net",
          "domain:werewolf.53site.com",
          "domain:windowsupdate.com",
          "domain:wkcdn.com",
          "domain:workflowy.com",
          "domain:xdrig.com",
          "domain:xiaojukeji.com",
          "domain:xiaomi.net",
          "domain:xiaomicp.com",
          "domain:ximalaya.com",
          "domain:xitek.com",
          "domain:xmcdn.com",
          "domain:xslb.net",
          "domain:xteko.com",
          "domain:yach.me",
          "domain:yixia.com",
          "domain:yunjiasu-cdn.net",
          "domain:zealer.com",
          "domain:zgslb.net",
          "domain:zimuzu.tv",
          "domain:zmz002.com",
          "domain:samsungdm.com"
        ]
      },
      {
        "type": "field",
        "port": null,
        "inboundTag": null,
        "outboundTag": "block",
        "ip": null,
        "domain": [
          "geosite:category-ads-all"
        ]
      },
      {
        "type": "field",
        "port": null,
        "inboundTag": null,
        "outboundTag": "direct",
        "ip": [
          "geoip:private"
        ],
        "domain": null
      },
      {
        "type": "field",
        "port": null,
        "inboundTag": null,
        "outboundTag": "direct",
        "ip": [
          "geoip:cn"
        ],
        "domain": null
      },
      {
        "type": "field",
        "port": null,
        "inboundTag": null,
        "outboundTag": "direct",
        "ip": null,
        "domain": [
          "geosite:cn"
        ]
      }
    ]
  }
}

6) 请附上出错时软件输出的错误日志。在 Linux 中,日志通常在 /var/log/v2ray/error.log 文件中。

服务器端错误日志:

2020/08/15 09:45:58 [Debug] v2ray.com/core/app/log: Logger started
2020/08/15 09:45:58 [Debug] v2ray.com/core/app/proxyman/inbound: creating stream worker on 0.0.0.0:21059
2020/08/15 09:45:58 [Info] v2ray.com/core/transport/internet/tcp: listening TCP on 0.0.0.0:21059
2020/08/15 09:45:58 [Warning] v2ray.com/core: V2Ray 4.27.0 started
2020/08/15 09:47:48 [Info] [1214700157] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from xxx.xxx.xxx.xxx:36296 > v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 33 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found
2020/08/15 09:48:48 [Info] [273729109] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from xxx.xxx.xxx.xxx:36337 > v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 0 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found
2020/08/15 09:49:48 [Info] [1392132641] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from xxx.xxx.xxx.xxx:35731 > v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 56 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found
2020/08/15 09:50:49 [Info] [1007915817] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: invalid request from xxx.xxx.xxx.xxx:34947 > v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 53 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found

客户端错误日志: v2rayN未配置日志信息,我手动修改配置文件并重启服务后我所修改的部分被清除了,所以无客户端日志。

    // 在这里附上客户端日志

7) 请附上访问日志。在 Linux 中,日志通常在 /var/log/v2ray/access.log 文件中。

2020/08/15 09:47:48 xxx.xxx.xxx.xxx:36296 rejected  v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 33 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found
2020/08/15 09:48:48 xxx.xxx.xxx.xxx:36337 rejected  v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 0 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found
2020/08/15 09:49:48 xxx.xxx.xxx.xxx:35731 rejected  v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 56 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found
2020/08/15 09:50:49 xxx.xxx.xxx.xxx:34947 rejected  v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 53 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found
2020/08/15 09:51:50 xxx.xxx.xxx.xxx:34964 rejected  v2ray.com/core/proxy/vmess/encoding: failed to drain connection DrainSize = 857 57 5 > v2ray.com/core/proxy/vmess/encoding: invalid user > v2ray.com/core/proxy/vmess: Not Found

8) 其它相关的配置文件(如 Nginx)和相关日志。 使用caddy v2,因为caddy v2与v1在语法上有些不同,所以我并不确定配置是否正确。

https://domain.me {
        encode gzip
        tls /etc/caddy/domain_me.crt /etc/caddy/domain_me.key
        reverse_proxy /v2 https://127.0.0.1:21059 {
                header_up Host "domain.me"
                header_up X-Forwarded-Proto "https"
                transport http {
                        tls_insecure_skip_verify
                }
        }
}

9) 如果 V2Ray 无法启动,请附上 --test 输出。

通常的命令为 /usr/bin/v2ray/v2ray --test --config /etc/v2ray/config.json。请按实际情况修改。

10) 如果 V2Ray 服务运行不正常,请附上 journal 日志。

通常的命令为 journalctl -u v2ray

请预览一下你填的内容再提交。

lxhao61 commented 4 years ago

caddy2刚正式支持v2ray H2C。v2ray 服务端要配置为H2C,即不启用TLS。v2ray 客户端要配置为H2。Caddy2开启TLS及反向代理。 原理图: v2ray client <----- H2 ------> caddy2 <-- H2C --> v2ray server 注意: 1、目前仅 caddy2 的 v2.2.0-rc.1 版及以后完美支持 v2ray 的 H2C,实现 H2(HTTP/2) 应用。 2、另 VLESS 协议配置类似。仅各自修改 v2ray 服务器与客户端对应协议及参数即可。 相关配置模板:https://github.com/veekxt/v2ray-template/tree/master/H2C%2Bvmess%2BCaddy2

CCBP commented 4 years ago

caddy2刚正式支持v2rayH2C。v2ray服务端要配置为H2C,即不启用TLS。v2ray客户端要配置为H2。Caddy2开启TLS及反向代理。 原理图: v2ray客户端<----- H2- ----> caddy2 <-H2C-> v2ray服务器 注意: 1,目前仅caddy2的v2.2.0-rc.1版及以后完美支持v2ray的H2C,实现H2(HTTP / 2)应用 。2,另VLESS协议配置类似。仅各自修改v2ray服务器与客户端对应协议及参数即可。 相关配置模板:https : //github.com/veekxt/v2ray-template/pulls

谢谢您的解答