"502 Bad Gateway

I have to put haproxy in front of my already running wildfly application server. Both haproxy and wildfly-server are on separate ubuntu machines. I had installed haproxy version 1.8.8-1 and it is working fine with http, but getting below error with https:- “502 Bad Gateway: The server returned an invalid or incomplete response”.