We have setup a Kubernetes cluster with Nginx. Within the cluster, we are running Elasticsearch and Kibana. Sometimes, when experimenting on Kibana DevTools console, we get a 502 bad gateway. The weird aspect is that it only happens through the console, and only 1 time every 4-5 queries. So most of the times it works. This is the error:

This is the nginx yaml configuration:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gateway-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
kubernetes.io/tls-acme: 'true'
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: "*"
nginx.ingress.kubernetes.io/cors-allow-headers: "*"
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
nginx.ingress.kubernetes.io/service-upstream: "true"
spec:
rules:
...
Nginx controller was installed by following this guide as we are using Oracle Cloud.
Most of the Q&A I have found around are related to server configurations issues. While here most of the times work, so it should not be a configuration issue.
I did not get any luck by reading up on https://kubernetes.github.io/ingress-nginx/. Worth to mention that I am using CloudFlare, but once again, in their documentation they say to check nginx configuration, as it is not on their end. https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors#502504error
Any insight is strongly appreciated.