title: How to get oauth2_proxy running in kubernetes under one domain to redirect back to original domain that required authentication?
body: <p>I've been setting up a kubernetes cluster and want to protect the dashboard (running at <code>kube.example.com</code>) behind the <code>bitly/oauth2_proxy</code> (running at <code>example.com/oauth2</code> on image <code>a5huynh/oauth2_proxy:latest</code>) as I want to re-use the OAuth proxy for other services I will be running. Authentication is working perfectly but after a user logs in, i.e. the callback returns, they are sent to <code>example.com</code> where instead they should be sent to the original host <code>kube.example.com</code> that initiated the flow. How can I do this? (I am using the nginx-ingress-controller).</p>
  
  <p>Annotation on OAuth2 Proxy:</p>
  
  <pre><code>kubernetes.io/ingress.class: "nginx",
  nginx.ingress.kubernetes.io/force-ssl-redirect: "true",
  nginx.ingress.kubernetes.io/secure-backends: "true",
  nginx.ingress.kubernetes.io/ssl-passthrough: "true"
  </code></pre>
  
  <p>Annotation on Dashboard:</p>
  
  <pre><code>kubernetes.io/ingress.class: "nginx",
  nginx.ingress.kubernetes.io/auth-signin: "https://example.com/oauth2/start",
  nginx.ingress.kubernetes.io/auth-url: "https://example.com/oauth2/auth",
  nginx.ingress.kubernetes.io/backend-protocol: "HTTPS",
  nginx.ingress.kubernetes.io/force-ssl-redirect: "true",
  nginx.ingress.kubernetes.io/secure-backends: "true",
  nginx.ingress.kubernetes.io/ssl-passthrough: "true",
  nginx.ingress.kubernetes.io/ssl-redirect: "true"
  </code></pre>
  
  <p>I expect to be redirected to the original host <code>kube.example.com</code> after OAuth flow is complete but am being sent back to the OAuth2 host <code>example.com</code></p>