2

I have 2 servers running same laravel app (laravel 5.3) and both are behind reverse proxy(nginx). for the session I set it to use redis. Also, I use cartalyst sentinel for user authentication.

let say the reverse Proxy is A, while servers for laravel are B and C.

The problem is:

When I log in A which is forwarding the request to B, and then the next request in A is forwarded to C.

When the request is forwarded to C, i can't pass the request because C see me as a guest not as an authenticate user.

how can I share session behind reverse proxy in different server?

config/cache.php

'default' => env('CACHE_DRIVER', 'redis'),
    'stores' => [
        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
        ],
    ],

config/session.php

'driver' => env('SESSION_DRIVER', 'redis'),
'connection' => 'session',

config/database.php

'redis' => [
        'cluster' => false,
        'default' => [
            'host' => env('REDIS_HOST', '192.168.1.102'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
            'prefix' => env('REDIS_PREFIX', 'prod'),
        ],
        'session' => [
         'host'     => env('REDIS_HOST', '192.168.1.102'),
         'password' => env('REDIS_PASSWORD', null),
         'port'     => env('REDIS_PORT', 6379),
         'database' => 1,
         'prefix' => env('REDIS_PREFIX', 'prod_session'),
   ],

update: 11 Oct 2017

I try using laravel default Auth and it's work. from my view point the problem is in cartalyst sentinel that not ready for use in horizontal scaling server.

Andi R
  • 112
  • 2
  • 13
  • may this would help : https://stackoverflow.com/a/25452425/2815635 & https://stackoverflow.com/a/36009319/2815635 – Niklesh Raut Oct 10 '17 at 12:02
  • i already try to use Session::getId() but it will have new id when the server behind reverse proxy is change, for the jwt I'll try your recommendation. – Andi R Oct 10 '17 at 12:20

0 Answers0