带有NGINX和Rails ActionCable的Websocket

时间:2018-07-17 13:31:49

标签: amazon-web-services nginx websocket actioncable

我们的配置有什么问题? NGINX没有添加适当的标题。

使用React前端通过wss连接初始化客户端,该连接由AWS ELB接收,未加密地传递给nginx,proxy_passed传递给Rails后端。

反应连接网址
wss://mydomain.com/ws/cable

nginx配置
location /ws/ { proxy_pass ​http://backend_host/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; }

在Rails中,ws失败here,因为nginx未正确设置env['HTTP_CONNECTION']env['HTTP_UPGRADE']

env['HTTP_CONNECTION']应该等于“ Upgrade”,而应该等于“ close”
env['HTTP_UPGRADE']应该等于“ websocket”,而不是

我们可以在nginx中进行哪些更改以修复这些标头?

0 个答案:

没有答案