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 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题