1. 程式人生 > >nginx使用wss協議出現wss handshake: Unexpected response code: 400

nginx使用wss協議出現wss handshake: Unexpected response code: 400

在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"; }