websocket-rails: getting 301 redirect on ssl connection while on http things work fine.
Hi, Im getting a 301 error when on https.
'wss://example-site.com/websocket' failed: Error during WebSocket handshake: Unexpected response code: 301
Here is my nginx configuration
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/example-site.com.crt;
ssl_certificate_key /etc/ssl/example-site.key;
server_name example-site.com www.example-site.com;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
root /home/ubuntu/example-site/current/public;
passenger_enabled on;
rails_env production;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /websocket {
proxy_pass http://localhost:3001/websocket;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
add_header Access-Control-Allow-Origin *;
proxy_set_header Upgrade websocket;
proxy_set_header Connection Upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite /websocket/(.*) /$1 break;
}
} `
any ideas as to why ? I had successfully configured this with http but this doesnt work on https. Any ideas or anyone encountered this anytime ?
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 1
- Comments: 15 (3 by maintainers)
@kesha-antonov - How do we get the action_name for /cable?
@pamio, thank you. Solved my problem. In production.rb I set
force_ssl=falseand in application_controller.rb I setforce_ssl if: "Rails.env.production? && action_name != 'dialog_chat'"