直连v2正常,经nginx转发则无法工作 Centos8



  • 猜测可能的原因有如下
    一是服务端nginx转发出现问题,二是v2rayN客户端的填写有问题(教程里是v2rayM的,host项填写差别有点大)

    ————客户端错误信息————
    2020/06/07 21:59:29 [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://www.example.xyz/user/accountsettings): 502 Bad Gateway > websocket: bad handshake] > v2ray.com/core/common/retry: all retry attempts failed
    ————————————————

    ————nginx配置文件————
    server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name xxx.xyz;
    root /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
    
        location / {
        }
    
        error_page 404 /404.html;
            location = /40x.html {
        }
    
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
    

    Settings for a TLS enabled server.

    server {
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name  xxx.xyz;
        root         /usr/share/nginx/html;
    
        ssl_certificate "/etc/letsencrypt/live/www.xxx.xyz/fullchain.pem";
        ssl_certificate_key "/etc/letsencrypt/live/www.xxx.xyz/privkey.pem";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers PROFILE=SYSTEM;
        ssl_prefer_server_ciphers on;
    

    # Load configuration files for the default server block.

    include /etc/nginx/default.d/*.conf;

        location / {
        }
        location /user/accountsettings {
              proxy_redirect off;
              proxy_pass http://127.0.0.1:40800;
              proxy_http_version 1.1;
    

    proxy_set_header Upgrade $http_upgrade;

              proxy_set_header Connection "upgrade";
              proxy_set_header Host $host;
              # Show real IP in v2ray access.log
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    

    ————————#注释掉了一条proxy set header是尝试修复,未成功

    ————v2配置文件————
    {
    "inbounds": [{
    "port": 40800,
    "protocol": "vmess",
    "settings": {
    "clients": [
    {
    "id": "xxx",
    "level": 1,
    "alterId": 0
    }
    ]
    },
    "streamSettings": {
    "networtrk": "ws",
    "wsSettings": {
    "path": "/user/accountsettings"
    }
    }
    }],
    "outbounds": [{
    "protocol": "freedom",
    "settings": {}
    },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
    }],
    "routing": {
    "rules": [
    {
    "type": "field",
    "ip": ["geoip:private"],
    "outboundTag": "blocked"
    }
    ]
    }
    }
    ————————————
    其中v2配置文件比较神奇的一点是我前边只要加log相关,v2则无法运行。。。

    希望有人能帮我看出问题在哪儿。



  • @zula nginx配置建议截图,看的不是很清楚


登录后回复