v2ray / v2ray-core

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

v2ray + Nginx 无法访问网页 #2229

Closed Souldream0816 closed 4 years ago

Souldream0816 commented 4 years ago

提交 Issue 之前请先阅读 Issue 指引,然后回答下面的问题,谢谢。 除非特殊情况,请完整填写所有问题。不按模板发的 issue 将直接被关闭。 如果你遇到的问题不是 V2Ray 的 bug,比如你不清楚要如何配置,请使用Discussion进行讨论。

1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明) V2Ray 4.22.1 2) 你的使用场景是什么?比如使用 Chrome 通过 Socks/VMess 代理观看 YouTube 视频。 Cent OS 7.5 + V2Ray + Nginx反向代理科学上网,笔记本通过Chrome访问google 3) 你看到的不正常的现象是什么?(请描述具体现象,比如访问超时,TLS 证书错误等) Google无法访问,V2RayN有报错日志 但是Nginx可以通过域名从Chrome正常访问 4) 你期待看到的正确表现是怎样的? 能够正常访问Google 5) 请附上你的配置(提交 Issue 前请隐藏服务器端IP地址)。

服务器端配置: V2Ray config.json

{
    "log":{
    "access":"/var/log/v2ray/access.log",
    "error":"/var/log/v2ray/error.log",
    "loglevel":"warning"
          },
  "inbounds": [{
    "port": 39656,
    "listen":"127.0.0.1",
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "*******-1fe8-4a97-b29d-c4ab8c82ae58",
          "level": 1,
          "alterId": 64
        }
      ]
    }
    "streamSettings":{
    "network":"ws",
    "wsSettings":{
    "path":"/usr/local/webserver/nginx/html"
    }
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
    "tag":"direct"
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "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"
      }
    ]

  }
}

客户端配置:

{
  "policy": null,
  "log": {
    "access": "",
    "error": "",
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "tag": "proxy",
      "port": 10808,
      "listen": "127.0.0.1",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "settings": {
        "auth": "noauth",
        "udp": true,
        "ip": null,
        "address": null,
        "clients": null
      },
      "streamSettings": null
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "proxy.**.cn",
            "port": 443,
            "users": [
              {
                "id": "*******-1fe8-4a97-b29d-c4ab8c82ae58",
                "alterId": 64,
                "email": "t@t.tt",
                "security": "aes-128-gcm"
              }
            ]
          }
        ],
        "servers": null,
        "response": null
      },
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "tlsSettings": {
          "allowInsecure": true,
          "serverName": "proxy.**.cn"
        },
        "tcpSettings": null,
        "kcpSettings": null,
        "wsSettings": {
          "connectionReuse": true,
          "path": "/usr/local/webserver/nginx/html",
          "headers": {
            "Host": "proxy.**.cn"
          }
        },
        "httpSettings": null,
        "quicSettings": null
      },
      "mux": {
        "enabled": true
      }
    },
    {
      "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": null,
  "api": null,
  "dns": null,
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "port": null,
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "ip": null,
        "domain": null
      }
    ]
  }
}

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

服务器端错误日志:

V2Ray 没有报错日志

客户端错误日志:

2020/02/08 21:18:38 tcp:127.0.0.1:13715 accepted tcp:clients2.google.com:443 [proxy] 
2020/02/08 21:18:42 [Warning] failed to handler mux client connection > 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://proxy.**.cn/usr/local/webserver/nginx/html): 502 Bad Gateway > websocket: bad handshake] > v2ray.com/core/common/retry: all retry attempts failed

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

    // 在这里附上服务器端日志

8) 其它相关的配置文件(如 Nginx)和相关日志。 Nginx 配置


events {
    worker_connections  1024;
}

http
{

server{
    listen 80;
    server_name proxy.**.cn;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2 default_server;
    server_name proxy.**.cn;

    ssl_certificate /usr/local/webserver/nginx/conf/**.cn.pem;
    ssl_certificate_key /usr/local/webserver/nginx/conf/**.cn.key;

    root /usr/local/webserver/nginx/html;
    index index.html;

    location /usr/local/webserver/nginx/html {
        proxy_redirect off;
        proxy_pass http://127.0.0.1:39656;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    }       
}

Nginx error.log 2020/02/08 21:22:50 [error] 21094#0: 3060 connect() failed (111: Connection refused) while connecting to upstream, client: 101.88.241.135, server: proxy..cn, request: "GET /usr/local/webserver/nginx/html HTTP/1.1", upstream: "http://127.0.0.1:39656/usr/local/webserver/nginx/html", host: "proxy..cn" 2020/02/08 21:22:52 [error] 21094#0: 3062 connect() failed (111: Connection refused) while connecting to upstream, client: 101.88.241.135, server: proxy..cn, request: "GET /usr/local/webserver/nginx/html HTTP/1.1", upstream: "http://127.0.0.1:39656/usr/local/webserver/nginx/html", host: "proxy..cn"

9) 如果 V2Ray 无法启动,请附上 --test 输出。 V2Ray 可以正常启动,在无Nginx情况下可以正常访问

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

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

通常的命令为 journalctl -u v2ray

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

kslr commented 4 years ago

服务端怎么会没有日志呢,你这是突然坏掉还是新机器

Souldream0816 commented 4 years ago

服务端怎么会没有日志呢,你这是突然坏掉还是新机器

解决了...服务器上v2ray的config.json 格式不对,用 --test --config看了下少逗号了...