nginx - RoR 5.0.0 ActionCable wss WebSocket handshake: Unexpected response code: 301 -
hello i'm trying serve simple chat using ror 5.0.0 beta (with puma) working on production mode (in localhost there no problems).
this nginx configuration:
upstream websocket { server 127.0.0.1:28080; } server { listen 443; server_name mydomain; ssl_certificate ***/server.crt; ssl_certificate_key ***/server.key; ssl on; ssl_session_cache builtin:1000 shared:ssl:10m; ssl_protocols tlsv1 tlsv1.1 tlsv1.2; ssl_ciphers high:!anull:!enull:!export:!camellia:!des:!md5:!psk:!rc4; ssl_prefer_server_ciphers on; access_log /var/log/nginx/jenkins.access.log; location / { proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header x-forwarded-proto $scheme; proxy_pass http://localhost:3000; proxy_read_timeout 90; proxy_redirect http://localhost:3000 https://mydomain; location /cable/{ proxy_pass http://websocket/; proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection "upgrade"; proxy_set_header host $http_host; break; } }
this config/redis/cable.yml
production: url: redis://localhost:6379/1
development: url: redis://localhost:6379/2
test: url: redis://localhost:6379/3
and config/environments/production.rb
# action cable endpoint configuration config.action_cable.url = 'wss://mydomain/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # force access app on ssl, use strict-transport-security, , use secure cookies. config.force_ssl = false
and error i'm receiving:
application-[...].js:27 websocket connection 'wss://mydomain/cable' failed: error during websocket handshake: unexpected response code: 301
any tips? :) thanks
i solved adding phusion passenger.
nginx config :
server{ listen 80; passenger_enabled on; passenger_app_env production; passenger_ruby /../ruby-2.3.0/ruby; root /path application/public; client_max_body_size 4g; keepalive_timeout 10; [...] location /cable{ passenger_app_group_name websocket; passenger_force_max_concurrent_requests_per_process 0; } }
you have remove default folder config/redis/cable.yml , move file /config only.
for ssl enable default ssl options , works .-)
thanks help
Comments
Post a Comment