Nginx bad gateway with SSL

I’m running Seafile Community Edition through a docker container. It was all working fine using normal HTTP (80) but I wanted to set it up through a secure connection using HTTPS (SSL). I did set SEAFILE_SERVER_LETSENCRYPT=true and finally got it working (I figure it out that I had to first let it create a certificate while still allowing port 80 connections before modifying the nginx file).

Everything is running trough a proxy (HAProxy). I have a proxy server which is accessed using the domain name. It will then forward that to the actual Seafile server. I think I have it set up correctly because when accessing said domain name, I can see the browser is receiving a valid certificate but the webpage displays 502 Bad gateway - nginx. So I know I’m accessing the Seafile server, it’s running through the proxy and the certificate is also valid/working. However, I’m not sure why I get a 502 error.