nginx配置wss连接方法: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header

2023-10-29 20:20:17
234

错误信息: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header

server {  
    listen 443 ssl;  
    server_name example.com;  
  
    ssl_certificate /path/to/certificate.pem;  
    ssl_certificate_key /path/to/private_key.pem;  
  
    location / {  
        proxy_pass http://localhost:8080;
        // 以下内容必须配置proxy_http_version 1.1;  
        proxy_set_header Upgrade $http_upgrade;  
        proxy_set_header Connection "upgrade";  
    }  
}