<p>I have ingress controller nginx with basic_auth</p>

<p>In my yaml I have:</p>

<pre><code>  annotations:
    nginx.ingress.kubernetes.io/auth-type: basic
    nginx.ingress.kubernetes.io/auth-secret: basic-auth
    nginx.ingress.kubernetes.io/auth-realm: "Authentication Required"
</code></pre>

<p>Everything works fine, but I need to exclude some IP addresses from basic_auth, and I can`t find a solution for it.</p>

<p>Does ingress have such opportunities?</p>

<p>You want to use custom server snippet and use allow/deny. I find it more elegant solution then the <code>if</code> recommentation in the comment above.</p>
<pre><code>  annotations:
    nginx.ingress.kubernetes.io/server-snippet: |
      satisfy  any;
      allow 66.220.144.0/20;
      deny   all;
</code></pre>
<p>To give credit where credit is due: This answer is based on <a href="https://serverfault.com/questions/242218/how-to-disable-http-basic-auth-in-nginx-for-a-specific-ip-range">https://serverfault.com/questions/242218/how-to-disable-http-basic-auth-in-nginx-for-a-specific-ip-range</a> .</p>
