我正在嘗試使用ActionCable(主要是複製DHH example)並嘗試使其在具有瘦(在端口8443上)和nginx的Ubuntu服務器上運行。這一切都在本地正常工作,但是,當我嘗試將其代理服務器上的活動服務器時,我得到此錯誤響應:failed: Error during WebSocket handshake: Unexpected response code: 301
。將nginx配置爲代理瘦和Rails ActionCable
這裏是我的我的nginx的配置的相關位:
server {
listen 80;
server_name _not_;
root /home/ubuntu/www/;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server 127.0.0.1:8443;
}
server {
listen 80;
...
location /websocket/ {
proxy_pass http://127.0.0.1:8443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
}
...
}
我有點出我的聯賽nginx的這裏的 - 我錯過什麼或得到錯誤的?
這是否會發生在60秒? – Anatoly
@Anoly它在60秒內打開/關閉嗎?它根本不連接到websocket。 – Michael
我不確定,我不認爲你的websockets服務器應該聽80. Il NGINX文檔,它聽8020. https://www.nginx.com/blog/websocket-nginx/ –