502 Bad Gateway, response from upstream server is blocked by haproxy

The upstream server was responding with invalid header names (whitespaces before the colon : in the response. So had to delete those headers in the config.