Tuesday, 6 November 2018

502 Bad Gateway nginx error on Kubernetes docker instance

We have taken a JSON Web Token approach to handle authorization in our Spring Boot application. Everything was working fine up to a point when we started getting 502 Bad Gateway errors for no reason (or, that's what we thought).

We discovered that this happened due to the token size which increased as we progressed with the development of functionality, which in turn resulted in the generation of a larger token based on additional authorization information.

The question still remains, why are we getting a 502 Bad Gateway. The HTTP 502 occurred due to the size of the header and on response to the HTTP request coming in, the kubernetes proxy rejected the request due to its header size.

So, we had to add the following line to the ingress of our application's docker descriptor:

  • ingress.kubernetes.io/proxy-buffer-size: 16k
That solved it. Hope it is of help to someone. :-)

1 comment:

  1. how did you debug it? how did you find out the error that it rejected it due to the header size? (THANKS)