我正在使用带有Nginx代理(Nginx v1.9)的Heroku路由器,并且对于websocket sockjs信息请求,出现以下错误:
2018-12-11T10:50:33.428630+00:00 heroku[router]:
cause="bad header" at=error code=H26 desc="Request
Error" method=GET path=
"/api/alarm/websock/alarms/info?t=1544489433394"
host=myapp.herokuapp.com request_id=68787415-4758-
46ba-8808-3addd8b5b7cf
fwd="109.51.167.61,54.78.201.187" dyno= connect=
service= status=400 bytes= protocol=https
在我的Nginx配置中,我具有以下位置块:
location /websock {
proxy_pass https://myapp.herokuapp.com/api/alarm/websock/alarms;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
如果我从位置块中删除升级和连接头,则不会再出现http错误400“错误头”,但是显然带有协议websocket的请求失败了……我怀疑没有发送连接头,或者被发送,但它是空的。
值得一提的是,在我的本地Nginx服务器(v1.11)中,相同的配置可以完美地工作,并且我可以发出websocket请求。
没有人知道为什么会这样以及如何解决吗?非常感谢
您对此有解决方案吗?我正在使用NGINX + Heroku,偶尔也会看到“错误的标头”响应。