ruby-on-rails – 在Elastic Beanstalk上使用Elasticache for Ra
发布时间:2020-12-17 01:57:16 所属栏目:百科 来源:网络整理
导读:我在Amazon Web Services上使用Elastic Beanstalk创建了一个Rails 5.0应用程序,并且我已经能够成功创建具有正常运行的数据库的网站.唯一的问题是我的应用程序需要ActionCable才能工作,我很难配置Elasticache并让rails app成功地与Elasticache集群通信. 很多
我在Amazon Web Services上使用Elastic Beanstalk创建了一个Rails 5.0应用程序,并且我已经能够成功创建具有正常运行的数据库的网站.唯一的问题是我的应用程序需要ActionCable才能工作,我很难配置Elasticache并让rails app成功地与Elasticache集群通信.
很多人告诉我,Elastic Beanstalk中的负载均衡器不允许与Elasticache集群进行任何通信,但我无法找到有关如何将Redis集成到Elastic Beanstalk以便正确配置ActionCable的任何文档. 你们是否知道使用Elasticache在Elastic Beanstalk Rails 5.0应用程序上成功设置ActionCable的一步一步详细方法? 解决方法
最重要的是将负载均衡器更改为用户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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |