Proxy_buffer_size : 502 bad gateway error

Hello KC team,

I need a help on below issue:

I have keycloak version 16.X on kubernetes cluster.
We are having now 502 bad gateway error. To resolve this few months back we have increased the ingress proxy buffer size as mentioned in known issue on git.

recently we are getting again 502 Error . So I’ve increased the proxy buffer size from 128k to 256k.
still issue is persist.

I would appreciate if you can help me .

Did you found any solution? I have exact same problem. Problem occurs when I’m passing JWT in callback uri.

Hi @Frostbourn ,

In my case I have increased proxy buffer size in ingress of keycloak and application as well

example for my problem:
Client having argo application and they have their own ingress in their namespace.
to solve the problem they have increased proxy buffer in argocd ingress.

please check from the application side as well.

If you have access, you should check the ingress logs. If you use ingress-nginx, nginx will show an error about buffer size in the logs.

In my case I solved problem by updating nginx.conf:

    location / {
      proxy_buffer_size   128k;
      proxy_buffers   4 256k;
      proxy_busy_buffers_size   256k;
    }

Thank you for your time guys.

The equivalent annotations in ingress-nginx are:

It is unclear if there is an equivalent annotation for proxy_busy_buffers_size .

In my experience, only the following annotation is needed. The other has sensible defaults:

nginx.ingress.kubernetes.io/proxy-buffer-size: “256k”

Here is an example of how to use this annotation in an Ingress resource:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-keycloak-ingress
  annotations:
    nginx.ingress.kubernetes.io/proxy-buffer-size: “256k”
    # Other annotations
spec:
  rules:
  #(…)