Hi all,
I am sending large post request to gunicorn/django behind nginx. If gunicorn responds and closes the connection before nginx has finished sending the large request body, it causes nginx to issue a 502 Bad Gateway response instead of the app server's response. This scenario happens e.g., if the endpoint requires authentication but the request is not authenticated (401 or 403).
More info here: https://github.com/benoitc/gunicorn/issues/872
As noted in the linked gunicorn issue, I've worked around this by making sure django waits for the entire request to come in before responding. Not sure if this is something you guys are interested in looking into, but thought I'd share.
Thanks,
Colin