dongzhanlu0658 2016-04-04 00:08
浏览 47
已采纳

使用AWS Elastic Beanstalk的Laravel 5.2中的会话不能与SESSION_DRIVER一起用作cookie,文件或数据库

I am trying to deploy a Laravel 5.2 app on AWS Elastic Beanstalk. Everything works fine, Except SESSIONS. Prior to deploying it on the Beanstalk, I had been working on the app on EC2, and I had no problems with sessions. For SESSION_DRIVER env option, I have tried database, cookie and file. They all worked on EC2 but none of them worked on Elastic Beanstalk.

After Googling and SOing a lot, I found out about Sticky Sessions. This is a setting you need to enable on the load balancer of your elastic beanstalk. This is available in the configuration dashboard of the elastic beanstalk.

So, I enabled Sticky Sessions, by choosing both, Use Load Balancer Generated Session AND Use App Generated Session option from the dropdown. Still the sessions don't work.

I have been looking around for other solutions but all routes point to Sticky Sessions.

Has anyone else faced this issue? If so, how did you solve it? Any help would be highly appreciated.

  • 写回答

1条回答 默认 最新

  • dqrnskni67375 2016-07-16 07:27
    关注

    On speaking with AWS Support, they suggested the following working solution.

    1. In your web app root, create a folder called .ebextensions
    2. Open any text editor and paste the following policy

      Resources:
       AWSEBLoadBalancer:
       Type: AWS::ElasticLoadBalancing::LoadBalancer
       Properties:
          Listeners:
          -   InstancePort: 80
              InstanceProtocol: HTTP
              LoadBalancerPort: 80
              PolicyNames:
              - CookiePolicy
              Protocol: HTTP
          AppCookieStickinessPolicy:
          -   CookieName: laravel_session
              PolicyName: CookiePolicy
      
    3. Save this file in the .ebextensions folder that you created in step 1.

    4. Redeploy the app to your beanstalk. Sessions should now be working
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python结合Matlab仿真忆阻器
  • ¥35 有人会注册whatsaop协议号吗?
  • ¥15 lead dbs 无法导入影像数据
  • ¥15 多目标MPA算法优化编程实现
  • ¥15 反激PWM控制芯片调研
  • ¥15 Python for loop减少运行时间
  • ¥15 fluent模拟物质浓度udf
  • ¥15 Collection contains no element matching the predicate
  • ¥20 冻品电商平台的搜索是怎么实现的
  • ¥15 如何搞一个可以控制、显示马达频率