【发布时间】:2015-05-20 06:59:36
【问题描述】:
我正在尝试将 nginx 配置为执行身份验证和 websockets 的反向代理。它代理将请求传递给 apache (/auth/wsgi) 以进行身份验证 - 一旦成功,它就会代理传递给 websocked 后端,这是 tomcat 8 上基于 java 的 websocket 端点。
location /basic/alerting/websocket {
auth_request /auth/wsgi;
proxy_pass http://backend.com:8080/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade "Websocket";
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
apache 认证成功。但是,在后端 tomcat 上,我收到此错误:
12572237 [http-nio-8080-exec-10] 错误 org.springframework.web.socket.server.support.DefaultHandshakeHandler - handleWebSocketVersionNotSupported() 由于不支持的 WebSocket 版本握手失败:null。支持的版本:[13]
似乎失败是因为后端期望没有通过的标头(“Sec-WebSocket-Version”)。我什至在 nginx 日志中看到:
2015/03/17 17:28:12 [debug] 20261#0: *718 http 代理标头:“Sec-WebSocket-Version: 13”
我需要在 nginx 配置中做些什么吗?非常感谢您的帮助。
【问题讨论】: