<p>I am using the nginx ingress controller with an AKS cluster.</p>
<p>The problem I have at the moment is that whenever a query string is added to a URL, nginx returns a 502 bad gateway.</p>
<p>The ingress is:</p>
<pre><code>kind: Ingress
metadata:
  name: myapp
  namespace: dh2
  labels:
    helm.sh/chart: myapp-0.1.0
    app.kubernetes.io/name: myapp
    app.kubernetes.io/instance: myapp-1680613380
    app.kubernetes.io/version: &quot;1.0.0&quot;
    app.kubernetes.io/managed-by: Helm
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - &quot;example.com&quot;
      secretName: qa-tls
  rules:
    - host: &quot;example.com&quot;
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: myapp-1680613380
                port:
                  number: 80
</code></pre>
<p>When I access <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a> everything works as expected. However if I pass any query string in the URL such as <a href="http://example.com/login?=1" rel="nofollow noreferrer">http://example.com/login?=1</a> I receive a 502.</p>
<p>I have tried to use Regex with the following annotation and path:</p>
<pre><code>nginx.ingress.kubernetes.io/rewrite-target: /$1
...
path: /(.*)
</code></pre>
<p>But this also fails to work. What am I missing?</p>

David Hirst
<p>It turns out that Rafael was onto something.</p>
<p>Having checked the controller logs it seems that an error was being thrown about the length of the URL.</p>
<p>Naturally I would have thought that nginx should have then thrown a 414 error but instead resorted to a 502. Since the issue is not with my ingress code Turing is correct that this should now be moved to ServerFault.</p>
<p>However all I needed to do with increase the buffer sizes on the nginx controller config map since it appears nginx has very small buffer sizes by default.</p>
<p>I simply added the following under data:</p>
<pre><code>  proxy-buffer-size: &quot;16k&quot;
  large-client-header-buffers: &quot;4 16k&quot;
</code></pre>
