title: How to handle Azure AD Authentication with Kubernetes Ingress
body: <p>I have an ASP.NET Core 2 application running in a pod. </p>
  
  <p>It is nothing fancy. Just the default app created by Visual Studio, with "School/Work account"-authentication enabled.</p>
  
  <p>My ingress points to the service at <code>/</code></p>
  
  <pre><code>- path: /
    backend:
      serviceName: debug-ui
      servicePort: 80
  </code></pre>
  
  <p>When i hit that endpoint (<code>/</code>) i am being redirected to Azure AD login. I authenticate and Azure AD redirects to <code>/signin-oidc</code> which is normal for AD login. So far everything works as expected.</p>
  
  <p>The problem is that the ingress responds with a "502 - Bad gateway", probably because the ingress sees <code>/signin-oidc</code> as a route to another (non-existing) service, but it should have been an endpoint on the application at <code>/</code> itself.</p>
  
  <p>The application running at <code>/</code> also have <code>/about</code> and a <code>/contact</code> - which works fine when auth is disabled</p>
  
  <p>The <code>/signin-oidc</code> is called as HTTP POST with the authentication token. (JWT)</p>
  
  <p>How do i get around this issue ?</p>
  
  <p>Technologies :</p>
  
  <ul>
  <li>Kubernetes on Azure ACS</li>
  <li>nginx-ingress-controller </li>
  <li>Azure Active Directory </li>
  <li>.NET Core 2</li>
  </ul>