【问题标题】:Configuring ActionCable with Elasticache for Rails 5.0 App on Elastic Beanstalk使用 Elasticache 为 Elastic Beanstalk 上的 Rails 5.0 应用程序配置 ActionCable
【发布时间】:2017-05-15 02:51:16
【问题描述】:

我已经在 Amazon Web Services 上使用 Elastic Beanstalk 创建了一个 Rails 5.0 应用程序,并且我已经能够成功地创建具有正常数据库的网站。唯一的问题是我的应用程序需要 ActionCable 才能工作,而且我很难配置 Elasticache 并使 rails 应用程序成功与 Elasticache 集群通信。

很多人告诉我,Elastic Beanstalk 中的负载均衡器不允许与 Elasticache 集群进行任何通信,而且我找不到任何有关如何将 Redis 集成到 Elastic Beanstalk 中的文档,以便正确配置 ActionCable。

你们知道使用 Elasticache 在 Elastic Beanstalk Rails 5.0 应用程序上成功设置 ActionCable 的分步详细方法吗?

【问题讨论】:

  • 你解决了吗?

标签: ruby-on-rails amazon-web-services


【解决方案1】:

最重要的是将负载均衡器更改为用户 TCP 和 SSL,而不是 HTTP 和 HTTPS。您还需要配置 nginx 以传递 /cable 位置上的升级标头。

尝试在您的 .ebextensions 文件夹中添加此文件 (nginx.config):

files:
  /etc/nginx/conf.d/proxy.conf:
    content: |
      client_max_body_size 500M;
      server_names_hash_bucket_size 128;

      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 *.cmgresearch.net;

        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;

          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 "websocket";
            proxy_set_header Connection "Upgrade";
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
        }
      }


container_commands:
  01restart_nginx:
    command: "service nginx restart"

https://blog.cmgresearch.com/2017/05/11/step-7-action-cable-on-elastic-beanstalk.html

【讨论】:

    猜你喜欢
    • 2018-06-13
    • 2016-09-18
    • 2019-02-23
    • 2013-11-25
    • 2017-08-02
    • 2018-04-14
    • 2017-03-18
    • 2012-09-24
    • 2017-04-19
    相关资源
    最近更新 更多