Redis
 sql >> Database >  >> NoSQL >> Redis

ActionCable su AWS:errore durante l'handshake WebSocket:codice di risposta imprevisto:404

Per eseguire l'esempio di chat websocket su una distribuzione Elastic Beanstalk a istanza singola in AWS, dovrai aggiungere la seguente configurazione proxy Nginx (Nota:sostituire "env1.t3tiiauce6.us-west-2.elasticbeanstalk.com" con il nome del sito):

.ebextensions/nginx_proxy.config

files:
  "/etc/nginx/conf.d/websockets.conf" :
    content: |
      upstream backend {
          server unix:///var/run/puma/my_app.sock;
      }

  server {
      listen 80;

      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;

      server_name env1.t3tiiauce6.us-west-2.elasticbeanstalk.com

      # prevents 502 bad gateway error
      large_client_header_buffers 8 32k;

      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_set_header X-NginX-Proxy true;

          # prevents 502 bad gateway error
          proxy_buffers 8 32k;
          proxy_buffer_size 64k;

          proxy_pass http://backend;
          proxy_redirect off;

          location /assets {
            root /var/app/current/public;
          }

          # enables WS support
          location /cable {
            proxy_pass http://backend;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
          }
      }
  }

container_commands:
  01restart_nginx:
    command: "nginx -t && service nginx reload"

`