<p>I've a simple kubernetes ingress network.</p>

<p>I need deny the access some critical paths like /admin or etc.</p>

<p>My ingress network file shown as below.</p>

<pre><code> apiVersion: extensions/v1beta1
 kind: Ingress
 metadata:
 name: ingress-test
 spec:
   rules:
   - host: host.host.com
   http:
      paths:
        - path: /service-mapping
      backend:
         serviceName: /service-mapping
         servicePort: 9042
</code></pre>

<p>How I can deny the custom path with kubernetes ingress network, with nginx annonations or another methods . </p>

<hr>

<p>I handle this issue with annotations shown as below . </p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
   name: nginx-configuration-snippet
   annotations:
      nginx.ingress.kubernetes.io/configuration-snippet: |

     server_tokens off;
     location DANGER-PATH {
    deny all;
    return 403;
  }

spec:
  rules:
   - host: api.myhost.com
   http:
  paths:
  - backend:
      serviceName: bookapi-2
      servicePort: 8080
    path: PATH 
</code></pre>

ColossusMark1
<p>You can use <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#server-snippet" rel="noreferrer">server-snippet</a> annotation. <a href="https://github.com/nginxinc/kubernetes-ingress/issues/161#issuecomment-322224255" rel="noreferrer">This</a> seems like exactly what you want to achieve.</p>
