【发布时间】:2017-09-06 00:51:01
【问题描述】:
当我将网站切换到 https 时,我收到了 actioncable 错误:
WebSocket connection to 'wss://domain.com/cable' failed: Error during
WebSocket handshake: Unexpected response code: 404
https 网站工作正常,但我得到一个 404 的 websocket 地址。我当前的设置使 SSL 在 ELB 处终止,并且 nginx 将 http 重定向到 https。我将 actioncable 与我的铁路服务器一起运行,而不是作为独立服务器运行。
如何在 中设置安全的 websocket?
这是我的 nginx 配置文件
upstream puma {
server unix://var/run/server.sock;
}
server {
listen 80;
server_name default_server;
root /var/www/apps/server/public;
location /cable {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_pass http://puma;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_next_upstream error;
if ($http_x_forwarded_proto != "https") {
rewrite ^(.*)$ https://$host$1 permanent;
}
proxy_pass http://puma;
...
}
这是ELB上的配置:
【问题讨论】:
-
将 ELB 侦听器从安全 HTTPS 更新为安全 TCP 成功了 - 请参阅 stackoverflow.com/questions/25730368/…
标签: ssl nginx amazon-elb actioncable