<p>Im trying to limit the number of concurrent connection to servers in my Nginx ingress.</p>

<p>is max_conns supported in Ngnix ingress? how can i edit or add it?</p>

<blockquote>
  <p>max_conns=number
  limits the maximum number of simultaneous active connections to the proxied server (1.11.5). Default value is zero, meaning there is no limit. If the server group does not reside in the shared memory, the limitation works per each worker process.</p>
</blockquote>

<p><a href="http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream" rel="nofollow noreferrer">http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream</a></p>

<p>exmple of an Nginx conf using max_conn</p>

<pre><code>upstream backend {
server backend1.example.com  max_conns=3;
server backend2.example.com;}
</code></pre>

<p>thanks</p>

<p>So, what needed to be done in order to add max_conns (or any other parameter that is not supported by the ingress configmap) - is to change the template.</p>

<p>changing the template /etc/nginx/template/nginx.tmpl like this:</p>

<pre><code>upstream {{ $upstream.Name }} {
    # Load balance algorithm; empty for round robin, which is the default
    {{ if ne $cfg.LoadBalanceAlgorithm "round_robin" }}
    {{ $cfg.LoadBalanceAlgorithm }};
    {{ end }}

    {{ if $upstream.UpstreamHashBy }}
    hash {{ $upstream.UpstreamHashBy }} consistent;
    {{ end }}

    {{ if (gt $cfg.UpstreamKeepaliveConnections 0) }}
    keepalive {{ $cfg.UpstreamKeepaliveConnections }};
    {{ end }}

    {{ range $server := $upstream.Endpoints }}server {{ $server.Address | formatIP }}:{{ $server.Port }} max_fails={{ $server.MaxFails }} fail_timeout={{ $server.FailTimeout }} max_conns=1;
    {{ end }}
}
</code></pre>

<p>(you can get the full file from the pod nginx-ingress-controller, just run bash on the pod and cat it)
will do the trick.
now create a configmap with the local nginx.tmpl:</p>

<pre><code>kubectl create configmap nginx-template --from-file=nginx.tmpl=/localpath/nginx.tmpl
</code></pre>

<p>and then mount a volume to the deployment with this yaml:</p>

<pre><code>        volumeMounts:
      - mountPath: /etc/nginx/template
        name: nginx-template-volume
        readOnly: true
  volumes:
    - name: nginx-template-volume
      configMap:
        name: nginx-template
        items:
        - key: nginx.tmpl
          path: nginx.tmpl
</code></pre>

<ul>
<li>i needed to restart my NGINX ingress manually but i edited the ReplicationController because i didn't have a deployment (i guess its because im on minikube)</li>
</ul>
