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 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示