<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>Fully agree with @Mozafar Gholami, you can change parameters using ConfigMap while deploying nginx or update your  current configuration.
To update parameters before installation suggest you next:</p>

<p>1.fetch chart to your local machine and unzip it:</p>

<pre><code>helm fetch stable/nginx-ingress

tar -xzf nginx-ingress-1.1.4.tgz
</code></pre>

<ol start="2">
<li>edit controller.config section in the values.yml</li>
</ol>

<p>example for you:</p>

<pre><code>controller:
  name: controller
  image:
    repository: quay.io/kubernetes-ingress-controller/nginx-ingress-controller
    tag: "0.21.0"
    pullPolicy: IfNotPresent
    # www-data -&gt; uid 33
    runAsUser: 33

  config:
    proxy-buffer-size: "128k"
    proxy-buffers: "4 256k"
</code></pre>

<p>3.check what will be added to new configmap</p>

<pre><code>helm   template . | less
</code></pre>

<p>4. install chart</p>

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

<p>Please keep in mind that:</p>

<ol>
<li><p>Instead of ConfigMaps you can change parameters with Annotations.</p></li>
<li><p>Unfortunately NOT ALL parameters can be changed in nginx-ingress by above approach.</p></li>
<li><p>For more information reading the <a href="https://github.com/nginxinc/kubernetes-ingress/blob/master/docs/configmap-and-annotations.md#Summary-of-ConfigMap-and-Annotations" rel="nofollow noreferrer">nginx-ingress customization</a> page where you can find all values you are able to change. For example in your case I wasnt able to update <code>proxy_busy_buffers_size</code> and <code>large_client_header_buffers</code> parameters.</p></li>
</ol>

<p>Hope this help you.</p>
