As mentioned on the Stackoverflow post[1] the issue is likely due to default proxy_buffer_size which is 4K and while there is an internal feature request to increase this the current workaround to to reduce proxy_buffer_size to 4K or lower.
[1] https://stackoverflow.com/questions/57294212/502-bad-gateway-error-upstream-sent-too-big-header-while-reading-response-head -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/bd72e832-aa58-47b4-8ca8-d4e832f88801%40googlegroups.com.