全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 12877|回复: 34

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

[复制链接]
发表于 2022-7-20 10:48:15 | 显示全部楼层 |阅读模式
本帖最后由 Jianrry 于 2022-7-24 16:28 编辑

这个问题已经困扰我3天了,一直没有解决,请教一下各位18cm的mjj该如何解决这个问题。

我使用了 docker compose 部署了 V2Ray 的 vmess + tls + ws 方案,容器可以正常运行,却一直无法连接。

下面的是我的配置文件,麻烦帮忙看一下,配置是否出错了。

docker-compose.yml (docker compose 配置文件)

  1. version: '3'

  2. services:

  3.     nginx:
  4.         # 镜像
  5.         image: nginx
  6.         # 容器名
  7.         container_name: nginx        
  8.         # 端口
  9.         ports:
  10.             # 80 端口
  11.             - "80:80"
  12.             # 443 端口
  13.             - "443:443"
  14.         # 数据卷   
  15.         volumes:
  16.             # Nginx 配置文件夹
  17.             - "./nginx/config:/etc/nginx/conf.d"
  18.             # Nginx 站点的根目录
  19.             - "./nginx/html:/html"
  20.             # Nginx 日志文件夹
  21.             - "./nginx/log:/log"
  22.             # SSL 证书文件夹
  23.             - "./nginx/ssl:/ssl"
  24.         # 在容器退出时,总是重启容器   
  25.         restart: always

  26.     v2ray:
  27.         # 镜像
  28.         image: v2ray/official
  29.         # 容器名
  30.         container_name: v2ray        
  31.         # 数据卷
  32.         volumes:
  33.             # V2Ray 配置文件
  34.             - ./v2ray/config/config.json:/etc/v2ray/config.json
  35.             # V2Ray 访问日志文件
  36.             - ./v2ray/log/access.log:/var/log/v2ray/access.log
  37.             # V2Ray 错误日志文件
  38.             - ./v2ray/log/error.log:/var/log/v2ray/error.log                                   
  39.         # 在容器退出时,总是重启容器   
  40.         restart: always
复制代码


v2ray.conf (Nginx 配置文件)

  1. server {

  2.   listen 443 ssl;
  3.   listen [::]:443 ssl;
  4.   
  5.   ssl_certificate       /path/to/cert/file;
  6.   ssl_certificate_key   /path/to/cert/file;
  7.   ssl_session_timeout 1d;
  8.   ssl_session_cache shared:MozSSL:10m;
  9.   ssl_session_tickets off;
  10.   
  11.   ssl_protocols         TLSv1.2 TLSv1.3;
  12.   ssl_ciphers           ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
  13.   ssl_prefer_server_ciphers off;
  14.   
  15.   server_name           domain.com;

  16.   # 与 V2Ray 配置中的 path 保持一致
  17.   location /v2ray {

  18.     # WebSocket协商失败时返回404
  19.     if ($http_upgrade != "websocket") {
  20.       return 404;
  21.     }

  22.     proxy_redirect off;

  23.     # 假设WebSocket监听在环回地址的10000端口上
  24.     proxy_pass http://v2ray:1024;
  25.     proxy_http_version 1.1;
  26.     proxy_set_header Upgrade $http_upgrade;
  27.     proxy_set_header Connection "upgrade";
  28.     proxy_set_header Host $host;
  29.    
  30.     # Show real IP in v2ray access.log
  31.     proxy_set_header X-Real-IP $remote_addr;
  32.     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

  33.   }

  34.   # 访问日志
  35.   access_log  /log/domain.com.log;

  36. }
复制代码


V2Ray 服务器配置文件


  1. {
  2.   "log": {
  3.     "loglevel": "warning",
  4.     "access": "/var/log/v2ray/access.log",
  5.     "error": "/var/log/v2ray/error.log"
  6.   },  
  7.   "inbounds": [
  8.     {
  9.       "port": 1024,
  10.       "listen":"127.0.0.1",
  11.       "protocol": "vmess",
  12.       "settings": {
  13.         "clients": [
  14.           {
  15.             "id": "uuid",
  16.             "alterId": 0
  17.           }
  18.         ]
  19.       },
  20.       "streamSettings": {
  21.         "network": "ws",
  22.         "wsSettings": {
  23.         "path": "/v2ray"
  24.         }
  25.       }
  26.     }
  27.   ],
  28.   "outbounds": [
  29.     {
  30.       "protocol": "freedom",
  31.       "settings": {}
  32.     }
  33.   ]
  34. }
复制代码


V2Ray 客户端配置文件



  1. // 通过 V2RayN 导出为客户端配置文件
  2. {
  3.   "policy": {
  4.     "system": {
  5.       "statsOutboundUplink": true,
  6.       "statsOutboundDownlink": true
  7.     }
  8.   },
  9.   "log": {
  10.     "access": "",
  11.     "error": "",
  12.     "loglevel": "warning"
  13.   },
  14.   "inbounds": [
  15.     {
  16.       "tag": "socks",
  17.       "port": 10808,
  18.       "listen": "127.0.0.1",
  19.       "protocol": "socks",
  20.       "sniffing": {
  21.         "enabled": true,
  22.         "destOverride": [
  23.           "http",
  24.           "tls"
  25.         ]
  26.       },
  27.       "settings": {
  28.         "auth": "noauth",
  29.         "udp": true,
  30.         "allowTransparent": false
  31.       }
  32.     },
  33.     {
  34.       "tag": "http",
  35.       "port": 10809,
  36.       "listen": "127.0.0.1",
  37.       "protocol": "http",
  38.       "sniffing": {
  39.         "enabled": true,
  40.         "destOverride": [
  41.           "http",
  42.           "tls"
  43.         ]
  44.       },
  45.       "settings": {
  46.         "udp": false,
  47.         "allowTransparent": false
  48.       }
  49.     },
  50.     {
  51.       "tag": "api",
  52.       "port": 59712,
  53.       "listen": "127.0.0.1",
  54.       "protocol": "dokodemo-door",
  55.       "settings": {
  56.         "udp": false,
  57.         "address": "127.0.0.1",
  58.         "allowTransparent": false
  59.       }
  60.     }
  61.   ],
  62.   "outbounds": [
  63.     {
  64.       "tag": "proxy",
  65.       "protocol": "vmess",
  66.       "settings": {
  67.         "vnext": [
  68.           {
  69.             "address": "domain.com",
  70.             "port": 443,
  71.             "users": [
  72.               {
  73.                 "id": "uuid",
  74.                 "alterId": 0,
  75.                 "email": "t@t.tt",
  76.                 "security": "auto"
  77.               }
  78.             ]
  79.           }
  80.         ]
  81.       },
  82.       "streamSettings": {
  83.         "network": "ws",
  84.         "security": "tls",
  85.         "tlsSettings": {
  86.           "allowInsecure": true,
  87.           "serverName": "domain.com"
  88.         },
  89.         "wsSettings": {
  90.           "path": "/v2ray",
  91.           "headers": {
  92.             "Host": "domain.com"
  93.           }
  94.         }
  95.       },
  96.       "mux": {
  97.         "enabled": false,
  98.         "concurrency": -1
  99.       }
  100.     },
  101.     {
  102.       "tag": "direct",
  103.       "protocol": "freedom",
  104.       "settings": {}
  105.     },
  106.     {
  107.       "tag": "block",
  108.       "protocol": "blackhole",
  109.       "settings": {
  110.         "response": {
  111.           "type": "http"
  112.         }
  113.       }
  114.     }
  115.   ],
  116.   "stats": {},
  117.   "api": {
  118.     "tag": "api",
  119.     "services": [
  120.       "StatsService"
  121.     ]
  122.   },
  123.   "routing": {
  124.     "domainStrategy": "IPIfNonMatch",
  125.     "domainMatcher": "linear",
  126.     "rules": [
  127.       {
  128.         "type": "field",
  129.         "inboundTag": [
  130.           "api"
  131.         ],
  132.         "outboundTag": "api",
  133.         "enabled": true
  134.       },
  135.       {
  136.         "type": "field",
  137.         "port": "0-65535",
  138.         "outboundTag": "proxy",
  139.         "enabled": true
  140.       }
  141.     ]
  142.   }
  143. }
复制代码


domain.com.log (Nginx 日志文件)

  1. 162.142.125.210 - - [19/Jul/2022:10:00:00 +0000] "GET / HTTP/1.1" 404 153 "-" "-"
  2. 162.142.125.210 - - [19/Jul/2022:10:00:00 +0000] "GET / HTTP/1.1" 404 153 "-" "Mozilla/5.0 (compatible; CensysInspect/1.1; +https://about.censys.io/)"
  3. 172.70.210.164 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  4. 172.70.210.164 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  5. 172.69.33.240 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
复制代码


V2Ray 服务端日志文件



  1. 2022/07/19 09:57:02 [Warning] v2ray.com/core: V2Ray 4.22.1 started
复制代码


V2Ray 客户端日志文件

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

  2. 配置成功
  3. [Vmess] V2Ray(v2ray***com:443)
  4. 启动服务(2022/7/19 18:35:25)...
  5. V2Ray 4.42.2 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.17.1 windows/386)
  6. A unified platform for anti-**ship.
  7. 2022/07/19 18:35:25 [Info] main/jsonem: Reading config: D:\Software\v2rayN-Core\config.json
  8. 2022/07/19 18:35:25 [Warning] V2Ray 4.42.2 started
  9. 2022/07/19 18:35:25 127.0.0.1:61280 accepted //mtalk.google.com:5228 [proxy]
  10. 2022/07/19 18:35:25 127.0.0.1:61281 accepted //bl3301.storage.live.com:443 [proxy]
  11. 2022/07/19 18:35:26 127.0.0.1:61286 accepted tcp:127.0.0.1:0 [api]
  12. 2022/07/19 18:35:30 127.0.0.1:61292 accepted //www.google.com:443 [proxy]
  13. 2022/07/19 18:35:30 127.0.0.1:61294 accepted //alive.github.com:443 [proxy]
  14. 2022/07/19 18:35:35 127.0.0.1:61308 accepted //alive.github.com:443 [proxy]
  15. 2022/07/19 18:35:36 [Warning] [2092548641] app/proxyman/outbound: failed to process outbound traffic > proxy/vmess/outbound: failed to find an available destination > common/retry: [transport/internet/websocket: failed to dial WebSocket > transport/internet/websocket: failed to dial to (wss://domain.com/v2ray): 502 Bad Gateway > websocket: bad handshake] > common/retry: all retry attempts failed
  16. 2022/07/19 18:35:36 127.0.0.1:61311 accepted //mtalk.google.com:5228 [proxy]
  17. 2022/07/19 18:35:39 [Warning] [2069622245] app/proxyman/outbound: failed to process outbound traffic > proxy/vmess/outbound: failed to find an available destination > common/retry: [transport/internet/websocket: failed to dial WebSocket > transport/internet/websocket: failed to dial to (wss://domain.com/v2ray): 502 Bad Gateway > websocket: bad handshake] > common/retry: all retry attempts failed
  18. 2022/07/19 18:35:39 127.0.0.1:61321 accepted //alive.github.com:443 [proxy]
  19. 2022/07/19 18:35:40 [Warning] [2041129081] app/proxyman/outbound: failed to process outbound traffic > proxy/vmess/outbound: failed to find an available destination > common/retry: [transport/internet/websocket: failed to dial WebSocket > transport/internet/websocket: failed to dial to (wss://domain.com/v2ray): 502 Bad Gateway > websocket: bad handshake] > common/retry: all retry attempts failed
  20. 2022/07/19 18:35:40 127.0.0.1:61326 accepted //www.google.com:443 [proxy]
复制代码
 楼主| 发表于 2022-7-24 13:11:42 | 显示全部楼层
感谢各位大佬的回复,现在问题已经解决了,以下是我的解决方案。

app/proxyman/outbound: failed to process outbound traffic > proxy/vmess/outbound: failed to find an available destination > common/retry

解决方案:将
  1. "listen":"127.0.0.1"
复制代码
改为
  1. "listen":"0.0.0.0"
复制代码
,或者直接删掉这一行,感谢 @huaxing0211 的回复。

注意事项:如果在本机安装 v2ray,则
  1. "listen":"127.0.0.1"
复制代码
。如果通过 docker 安装 v2ray,则
  1. "listen":"0.0.0.0"
复制代码


rejected  v2ray.com/core/proxy/vmess/encoding: invalid user

解决方案:
  1. "alterId": 0
复制代码
改为
  1. "alterId": 64
复制代码
,感谢 @time12sads 的回复。

注意事项:在最新版本的 v2ray 中,这一项参数发生了变化,alterId 个人不建议为 0。



发表于 2022-7-20 10:52:39 | 显示全部楼层
本帖最后由 摩卡 于 2022-7-20 10:56 编辑

看下nginx的日志 有没有转发到v2容器
另外我看v2容器没有配置端口号 你配置下端口映射规则试试?
发表于 2022-7-20 10:52:32 | 显示全部楼层
用aapanrl面板吧。方便管理https://daima.eu.org/post/bt-v2ray/
发表于 2022-7-20 11:01:52 | 显示全部楼层
别的不说,先校时,保证二者相差不超过90s
发表于 2022-7-20 11:04:56 | 显示全部楼层
domain.com 是本来就是这样写的,还是你打码了的
 楼主| 发表于 2022-7-20 11:07:57 | 显示全部楼层
本帖最后由 Jianrry 于 2022-7-20 11:11 编辑
摩卡 发表于 2022-7-20 10:52
看下nginx的日志 有没有转发到v2容器
另外我看v2容器没有配置端口号 你配置下端口映射规则试试? ...


我不知道如何判断是否转发,麻烦大佬帮我看一下,下面是 nginx 的日志文件。

  1. [code]162.142.125.210 - - [19/Jul/2022:10:00:00 +0000] "GET / HTTP/1.1" 404 153 "-" "-"
  2. 162.142.125.210 - - [19/Jul/2022:10:00:00 +0000] "GET / HTTP/1.1" 404 153 "-" "Mozilla/5.0 (compatible; CensysInspect/1.1; +https://about.censys.io/)"
  3. 172.70.210.164 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  4. 172.70.210.164 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  5. 172.69.33.240 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  6. 172.69.33.240 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  7. 172.68.254.38 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  8. 172.69.33.240 - - [19/Jul/2022:10:00:06 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  9. 172.68.254.38 - - [19/Jul/2022:10:00:07 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  10. 172.70.214.84 - - [19/Jul/2022:10:00:07 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  11. 172.69.33.240 - - [19/Jul/2022:10:00:07 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
  12. 172.69.33.240 - - [19/Jul/2022:10:00:07 +0000] "GET /v2ray HTTP/1.1" 502 157 "-" "Go-http-client/1.1"
复制代码

另外我看v2容器没有配置端口号 你配置下端口映射规则试试?


v2 容器用的是 1024 端口,通过 nginx 反向代理转发到 443 端口,443 端口映射为本机的 443 端口,这个已经配置了。

V2Ray 服务器配置文件


  1. ...
  2. "inbounds": [
  3.     {
  4.       "port": 1024,
  5. ...
复制代码


v2ray.conf (Nginx 配置文件)

  1. ...
  2.     # 假设WebSocket监听在环回地址的10000端口上
  3.     proxy_pass http://v2ray:1024;
  4. ...
复制代码


docker-compose.yml (docker compose 配置文件)

  1. ...
  2.         # 端口
  3.         ports:
  4.             # 80 端口
  5.             - "80:80"
  6.             # 443 端口
  7.             - "443:443"
  8. ...
复制代码
 楼主| 发表于 2022-7-20 11:09:07 | 显示全部楼层
toot 发表于 2022-7-20 10:52
用aapanrl面板吧。方便管理https://daima.eu.org/post/bt-v2ray/

不习惯用面板,习惯用 docker 一把梭了。。。
 楼主| 发表于 2022-7-20 11:10:49 | 显示全部楼层
汤家凤 发表于 2022-7-20 11:01
别的不说,先校时,保证二者相差不超过90s

已经修改时区 和 校时 了,服务器时间和本机时间相差不到1min.
发表于 2022-7-20 11:12:17 | 显示全部楼层
nginx 报错502 说明连接不到后端

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

要么用link关联 要么定义一个网络两个容器加入

参考 https://docs.docker.com/compose/networking/
 楼主| 发表于 2022-7-20 11:14:00 | 显示全部楼层
CC大魔王 发表于 2022-7-20 11:04
domain.com 是本来就是这样写的,还是你打码了的

打了码,将 我的域名修改为了 domain.com ,为了防止别人恶意攻击。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-3-29 16:12 , Processed in 0.075785 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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