title: laravel session on different server
body: <p>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.</p>
  
  <p>let say the reverse Proxy is A, while servers for laravel are B and C.</p>
  
  <p><strong>The problem is:</strong> </p>
  
  <p>When I log in A which is forwarding the request to B, and then the next request in A is forwarded to C.</p>
  
  <p>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.</p>
  
  <p><strong>how can I share session behind reverse proxy in different server?</strong></p>
  
  <p>config/cache.php</p>
  
  <pre><code>'default' =&gt; env('CACHE_DRIVER', 'redis'),
      'stores' =&gt; [
          'redis' =&gt; [
              'driver' =&gt; 'redis',
              'connection' =&gt; 'default',
          ],
      ],
  </code></pre>
  
  <p>config/session.php</p>
  
  <pre><code>'driver' =&gt; env('SESSION_DRIVER', 'redis'),
  'connection' =&gt; 'session',
  </code></pre>
  
  <p>config/database.php</p>
  
  <pre><code>'redis' =&gt; [
          'cluster' =&gt; false,
          'default' =&gt; [
              'host' =&gt; env('REDIS_HOST', '192.168.1.102'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; env('REDIS_PORT', 6379),
              'database' =&gt; 0,
              'prefix' =&gt; env('REDIS_PREFIX', 'prod'),
          ],
          'session' =&gt; [
           'host'     =&gt; env('REDIS_HOST', '192.168.1.102'),
           'password' =&gt; env('REDIS_PASSWORD', null),
           'port'     =&gt; env('REDIS_PORT', 6379),
           'database' =&gt; 1,
           'prefix' =&gt; env('REDIS_PREFIX', 'prod_session'),
     ],
  </code></pre>
  
  <hr>
  
  <p>update: 11 Oct 2017</p>
  
  <p>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.</p>