全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
楼主: Jianrry

[已解决] [已解决] V2Ray 一直无法连接,有报错信息

[复制链接]
发表于 2022-7-20 11:20:09 | 显示全部楼层
你更新了吗? 新版的v2ray 的配置中, alterId 的值必须得是 64
 楼主| 发表于 2022-7-20 11:22:11 | 显示全部楼层
一颗赛艇 发表于 2022-7-20 11:12
nginx 报错502 说明连接不到后端

再看你的docker compose文件,两个容器之间没有定义关联网络,两个容器网 ...

https://docs.docker.com/compose/networking/

For example, suppose your app is in a directory called myapp, and your docker-compose.yml looks like this:

version: "3.9"
services:
  web:
    build: .
    ports:
      - "8000:8000"
  db:
    image: postgres
    ports:
      - "8001:5432"
When you run docker-compose up, the following happens:

A network called myapp_default is created.
A container is created using web’s configuration. It joins the network myapp_default under the name web.
A container is created using db’s configuration. It joins the network myapp_default under the name db.

Each container can now look up the hostname web or db and get back the appropriate container’s IP address. For example, web’s application code could connect to the URL postgres://db:5432 and start using the Postgres database.

It is important to note the distinction between HOST_PORT and CONTAINER_PORT. In the above example, for db, the HOST_PORT is 8001 and the container port is 5432 (postgres default). Networked service-to-service communication uses the CONTAINER_PORT. When HOST_PORT is defined, the service is accessible outside the swarm as well.

Within the web container, your connection string to db would look like postgres://db:5432, and from the host machine, the connection string would look like postgres://{DOCKER_IP}:8001.


如上所示,在3.9版本的 docker compose 中,同一个 docker-compose.yml 中存在2个容器 web 和 db。

1. 会自动创建一个网络,自动命名为 web_db_default

2. 这2个容器会自动加入此默认的网络 web_db_default

3. web 可以通过 "db:8001" 直接访问 db 这个容器的 8001 端口。

当然用 link 直接指定一个网络,让2个容器加入也可以。
发表于 2022-7-20 11:24:50 | 显示全部楼层
你的域名没有申请成功ssl啊。
server {

  listen 443 ssl;
  listen [::]:443 ssl;
  
  ssl_certificate       /path/to/cert/file;
  ssl_certificate_key   /path/to/cert/file;
发表于 2022-7-20 11:37:51 | 显示全部楼层
"listen":"127.0.0.1",
docker里用0.0.0.0,或是删除,默认
发表于 2022-7-20 11:38:27 | 显示全部楼层
本帖最后由 wachyi 于 2022-7-20 11:39 编辑

docker配置要改成这样

  1. v2ray:
  2.         # 镜像
  3.         image: v2ray/official
  4.         # 容器名
  5.         container_name: v2ray        
  6.         # 数据卷
  7.         ports:
  8.             - "1024:1024"
  9.         volumes:
  10.             # V2Ray 配置文件
  11.             - ./v2ray/config/config.json:/etc/v2ray/config.json
  12.             # V2Ray 访问日志文件
  13.             - ./v2ray/log/access.log:/var/log/v2ray/access.log
  14.             # V2Ray 错误日志文件
  15.             - ./v2ray/log/error.log:/var/log/v2ray/error.log                                   
  16.         # 在容器退出时,总是重启容器   
  17.         restart: always
复制代码
 楼主| 发表于 2022-7-20 11:40:09 | 显示全部楼层
本帖最后由 Jianrry 于 2022-7-24 13:17 编辑
time12sads 发表于 2022-7-20 11:20
你更新了吗? 新版的v2ray 的配置中, alterId 的值必须得是 64


下面回复的内容不正确,请参考置顶的那一条回复,下面回复的内容作废。

https://www.v2fly.org/config/protocols/vmess.html#outboundconfigurationobject

  1. 在 v4.28.1 版本后,客户端 AlterID 设置为 0 代表启用 VMessAEAD ;服务端为自动适配,可同时兼容启用和未开启 VMessAEAD 的客户端。

  2. 对于 VMess MD5 认证信息的兼容可以被关闭。(v4.35.0+)
复制代码

VMessAEAD 协议已经经过同行评议并已经整合了相应的修改。 VMess MD5 认证信息 的淘汰机制已经启动。

自 2022 年 1 月 1 日起,服务器端将默认禁用对于 MD5 认证信息 的兼容。任何使用 MD5 认证信息的客户端将无法连接到禁用 VMess MD5 认证信息的服务器端。

在服务器端可以通过设置环境变量 v2ray.vmess.aead.forced = true 以关闭对于 MD5 认证信息的兼容。 或者 v2ray.vmess.aead.forced = false 以强制开启对于 MD5 认证信息 认证机制的兼容 (不受到 2022 年自动禁用机制的影响) 。 (v4.35.0+)


服务端:V2Ray 4.22.1

客户端:V2Ray 4.42.2

我的 alterId 应该设置为 0 吧
 楼主| 发表于 2022-7-20 12:40:58 | 显示全部楼层
wjhhxl 发表于 2022-7-20 11:24
你的域名没有申请成功ssl啊。
server {

我的域名已经申请了证书,用的是 cloudflare 的15年证书,cloudflare 的 tls 设置为 full 模式。

/path/to/cert/file 的内容已经隐藏了,证书的文件名是我的域名,为了避免被人恶意攻击,所以隐藏了这个路径。
 楼主| 发表于 2022-7-20 12:47:42 | 显示全部楼层
本帖最后由 Jianrry 于 2022-7-20 17:31 编辑
huaxing0211 发表于 2022-7-20 11:37
"listen":"127.0.0.1",
docker里用0.0.0.0,或是删除,默认


非常感谢大佬的回复,问题就是出在这里。

刚才按照大佬的回复,修改完配置文件之后。

v2ray 多出了访问日志 access.log,之前的 access.log 的内容一直为空,现在 nginx 已经转发到 v2ray 了。

又出现了新的问题,还没有解决,大佬能再帮忙看一下吗?

v2ray 访问日志 access.log

  1. 2022/07/20 04:34:18 [2409:8a55:4e97:3e20:5cb2:69ba:f042:cf3f]:58494 rejected  v2ray.com/core/proxy/vmess/encoding: invalid user
  2. 2022/07/20 04:34:18 [2409:8a55:4e97:3e20:5cb2:69ba:f042:cf3f]:58492 rejected  v2ray.com/core/proxy/vmess/encoding: failed to read request header > websocket: close 1000 (normal)
复制代码


网上的回复说与时间有关,需要校对时间。

我已经尝试过了修改服务器的时区为上海时区,通过 ntpdate -u time.windows.com 校对时间,误差不超过1s ,本地电脑的时间也校对过了。

重新检查了一下 v2ray 的配置文件,但是还没有发现问题。

麻烦路过的各位大佬,多多指点一下。

发表于 2022-7-20 15:22:36 | 显示全部楼层
本帖最后由 huaxing0211 于 2022-7-20 15:30 编辑
Jianrry 发表于 2022-7-20 12:47
非常感谢大佬的回复,问题就是出在这里。

刚才按照大佬的回复,修改完配置文件之后。


uuid是一致的么?如空格?

date -R 看下时间和时区。

另外:
proxy_pass http://v2ray:1024;
docker默认网络最好不要用容器名来访问,要使用容器名来指代,最最好新建一个网络。(因重启什么的,可能会造成容器的ip改变,内部ip映射表没更新话,直接容器名访问就会有问题……)
 楼主| 发表于 2022-7-20 17:29:34 | 显示全部楼层
wachyi 发表于 2022-7-20 11:38
docker配置要改成这样

谢谢你的回复,不是这个的问题,主要的问题是 V2Ray 容器没有监听到网卡。

用的是 V2Ray 的容器,应该 listen 0.0.0.0 而不是 127.0.0.1。

V2Ray 的 1024 端口已经转发到 Nginx 的 443 端口,不需要暴露 1024 端口了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-25 22:28 , Processed in 0.070637 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表