I have a Django REST Framework app running behind an Nginx proxy, we have a third party service that redirects to one of the urls in the app. I'm getting 502s from this endpoint when the redirect happens and have narrowed it down to the Referer header being too large. My logic is as follows:
I've tried increasing my uwsgi buffer-size and nginx proxy buffer.
In more technical words, A 502 Bad Gateway means that the proxy (gateway) server wasn't able to get a valid or any response from the upstream server. If you are seeing a 502 bad gateway error on a website, it means that the origin server sent out an invalid response to another server that acted as a gateway or proxy.
After a number of hours trying out different things, the reason was in fact the uwsgi buffer-size just not being high enough even though I had quadrupled it. For those that don't know, you need to add:
buffer-size=32768
Where the number is some number of bytes that works for your use case. The default is 4096.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With