title: nginx proxy all request through authentication service
body: <p>Consider a dockerized environment containing the following containers:</p>
  
  <ol>
  <li>Backend API </li>
  <li>Front-end REACT App served using pushstate-server</li>
  <li>Authentication Service</li>
  <li>Nginx Container</li>
  </ol>
  
  <p>My nginx.conf contains the following:</p>
  
  <pre><code>server {
      listen 8080;        
  
      location / {
          auth_request /auth;
          proxy_pass http://frontend:5000;
      }       
  
      location = /auth {
          proxy_pass http://auth:6000;
      }
  
      error_page 403 = @error403;
      location @error403 {
          rewrite ^ /login$1;
          proxy_pass http://frontend:5000;
      }
  }
  </code></pre>
  
  <p>When the <code>auth_request /auth;</code> line is commented out, everything works just fine and all frontend pages can be accessed.</p>
  
  <p>As soon as I introduce the <code>auth_request</code> I can see the authentication service return a 403 however, it does not look like Nginx proxies to the login page.</p>
  
  <p>What am I doing wrong?</p>