nginx使用wss协议出现wss handshake: Unexpected response code: 400

£神魔★判官ぃ 2022-07-12 14:59 423阅读 0赞

在nginx中配置好https协议之后,我以为可以使用反向代理在tomcat容器中的页面js调用websocket用wss了,但是没想到居然报了个错:

  1. handshake: Unexpected response code: 400

查了一下官网才发现原来在配置反向代理的时候,如果需要使用wss,还需要加上如下配置:

  1. location /wsapp/ {
  2. proxy_pass http://wsbackend;
  3. proxy_http_version 1.1;
  4. proxy_set_header Upgrade $http_upgrade;
  5. proxy_set_header Connection "upgrade";
  6. }

官网链接:https://www.nginx.com/blog/websocket-nginx/

发表评论

表情:
评论列表 (有 0 条评论,423人围观)

还没有评论,来说两句吧...

相关阅读