<p>Greetings fellow humans,</p>
<p>i am trying to route all traffic incoming to my cluster with the following annotation:</p>
<pre><code>nginx.ingress.kubernetes.io/auth-url: http://my-auth-service/
</code></pre>
<p>I followed the tutorials and i still have not achieved to route every request to my auth module. I am following a strategy of master-minion. When I check the constructed nginx file the annotation is not found.</p>
<p>I tried as well something like this in one of my minon ingress files</p>
<pre><code>auth_request /auth;
auth_request_set $auth_service $upstream_http_auth_service;
proxy_pass    $request_uri
proxy_set_header X-foo-Token $auth_service;
</code></pre>
<p>I am using the following ingress controller version</p>
<pre><code>Image:       nginx/nginx-ingress:1.8.1
Ports:       80/TCP, 443/TCP, 9113/TCP, 8081/TCP
Host Ports:  0/TCP, 0/TCP, 0/TCP, 0/TCP
</code></pre>
<p>Samples:</p>
<p><strong>Master ingress</strong></p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: master-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.org/mergeable-ingress-type: &quot;master&quot;
    kubernetes.io/ingress.global-static-ip-name: &lt;cluster-ip&gt;
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
    # nginx.ingress.kubernetes.io/auth-url: http://my-auth-service/
spec:
  tls:
  - hosts:
    - app.myurl.com
    secretName: secret-tls

  rules:
  - host: app.myurl.com
</code></pre>
<p><strong>Minion ingress</strong></p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: pod-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.org/mergeable-ingress-type: &quot;minion&quot;

    # nginx.ingress.kubernetes.io/auth-url: http://my-auth-service/
    # nginx.ingress.kubernetes.io/auth-snippet: |
      # auth_request /new-auth-service;
      # auth_request_set $new_auth_service $upstream_http_new_auth_service;
      # proxy_pass    $request_uri
      # proxy_set_header X-foo-Token $new_auth_service;
    nginx.org/rewrites: &quot;serviceName={{ .Values.serviceName }} rewrite=/&quot;
spec:
  rules:
  - host: {{ .Values.clusterHost }} 
    http:
      paths:
      - path: /{{ .Values.serviceName }}/
        backend:
          serviceName: {{ .Values.serviceName }}
          servicePort: 80

</code></pre>

graned
<p>so i was able to make it work. First of all, the urls provided by <code>matt-j</code> helped be a lot to figure out a solution.</p>
<p>Turns out that i was using <code>nginx-stable</code> for my ingress controller, as in the documentation <a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">here</a> suggested, i needed to use the new ingress controller version. i followed the instructions for a full reset, since i am working on my staging env. (for production i might go with a 0 downtime approach). Once installed, I ran into an known issue which is related to the webhooks, similar error can be seen <a href="https://github.com/kubernetes/ingress-nginx/issues/5401" rel="nofollow noreferrer">here</a>. Basically one solution for overcoming this error is to delete the <code>validatingwebhookconfigurations</code>. Finally I applied the ingress config and made some adjustments to use the proper annotations, which made the magic.</p>
<p>NOTE: I ran into an issue regarding of how forwarding the auth request to my internal cluster service, to fix that i am using the FQDN of kubernetes pod.</p>
<p>NOTE 2: I removed the concept of master minion, since they the merging in kubernetes/ingress-nginx happens automatically more info <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/" rel="nofollow noreferrer">here</a></p>
<p>Here are the fixed samples:</p>
<p>MAIN INGRESS</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: master-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    kubernetes.io/ingress.global-static-ip-name: &lt;PUBLIC IP&gt;
spec:
  rules:
  - host: domain.com
</code></pre>
<p>CHILD INGRESS</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ .Values.serviceName }}-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/auth-url: http://&lt;SERVICE NAME&gt;.&lt;NAMESPACE&gt;.svc.cluster.local # using internal FQDN 
spec:
  rules:
  - host: {{ .Values.clusterHost }} 
    http:
      paths:
      - path: /{{ .Values.serviceName }}(/|$)(.*)
        backend:
          serviceName: {{ .Values.serviceName }}
          servicePort: 80
</code></pre>
