nginx反向代理 报错:Error during WebSocket handshake: Unexpected response code: 403

Posted Fantasy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx反向代理 报错:Error during WebSocket handshake: Unexpected response code: 403相关的知识,希望对你有一定的参考价值。

遇到nginx报错:websocket wss failed: Error during WebSocket handshake: Unexpected response code: 403

  server {
    listen 6340;
    location / {
      proxy_pass http://web;
      proxy_http_version 1.1;        #Nginx在与Node后端通信时使用HTTP/1.1,是WebSockets所必需的
      proxy_set_header Origin '';
      proxy_set_header Upgrade $http_upgrade;    #Nginx响应升级请求,当浏览器想要使用WebSocket时,该请求由HTTP启动
      proxy_set_header Connection "Upgrade";
    }
  }

代理 TCP和UDP

stream {
  upstream pptcp {
    server 10.10.10.10:9994;
    server 10.10.10.11:9994;
    }
  server {
    listen 9994;
    proxy_pass pptcp;
    proxy_connect_timeout 10s;
    proxy_timeout 3h;
    }
  upstream ppudp {
    server 10.10.10.10:9995;
    server 10.10.10.11:9995;
    }
  server {
    listen 9995 udp;
    proxy_pass ppudp;
    proxy_connect_timeout 10s;
    proxy_timeout 3h;
    }
  }

以上是关于nginx反向代理 报错:Error during WebSocket handshake: Unexpected response code: 403的主要内容,如果未能解决你的问题,请参考以下文章

Nginx下https反向代理转发无效问题

nginx配置反向代理

Nginx实现反向代理

nginx反向代理报错400

Nginx配置文件(反向代理服务器)

Nginx反向代理和负载均衡实战