首页 > 系统相关 >nginx使用wss协议出现wss handshake: Unexpected response code: 400

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

时间:2022-11-24 17:34:21浏览次数:64  
标签:handshake Unexpected http nginx wss code proxy websocket


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

handshake: Unexpected response code: 400

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

location /wsapp/ {
proxy_pass http://wsbackend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

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


标签:handshake,Unexpected,http,nginx,wss,code,proxy,websocket
From: https://blog.51cto.com/u_15890522/5884392

相关文章