<p>According to this article one need to set some nginx properties when running a .NET Core 2.x application using https and Azure AD Authentication behind Nginx in a Kubernetes cluster:</p>

<p><a href="https://stackoverflow.com/questions/48964429/net-core-behind-nginx-returns-502-bad-gateway-after-authentication-by-identitys">.Net Core behind NGINX returns 502 Bad Gateway after authentication by IdentityServer4</a></p>

<p>The answer outlines how to do this for a regular Nginx installation, but I would like to do this when installing Nginx in a Kubernetes cluster using Helm.</p>

<p>These are the Nginx properties one need to set:</p>

<pre><code>nginx.conf:
    http{
    ...
    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;
    large_client_header_buffers 4 16k;
    ...
    }


default.conf:
location /{
    ...
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    ...
}
</code></pre>

<p>The command I use to install Nginx in the Kubernetes cluster is:</p>

<pre><code>helm install stable/nginx-ingress --namespace kube-system
</code></pre>

<p>How does one set the above properties when installing Nginx using Helm in a Kubernetes cluster?</p>

<p>I found that the simplest solution is to use annotations on the Nginx ingress like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/proxy-buffer-size: "16k"
    nginx.ingress.kubernetes.io/rewrite-target: /
...
</code></pre>
