Can you give some more information about your setup? Without seeing configuration files and understanding your infrastructure it’s very difficult to troubleshoot an issue with only “I see a 502 Bad Gateway error”
If you don’t want to modify the LB docker images, the most normal way of doing something like this would be to have:
[internet] --HTTPS--> [load balancer] --HTTP--> [listenbrainz]
In this case you could use nginx or haproxy as your load balancer, like in the examples that you linked. Note that the connection between the load balancer and application server is HTTP only. Because the listenbrainz server can’t speak HTTPS and doesn’t have a certificate, it’s much easier to do it this way.
I assume you already have a load balancer with nginx set up with an HTTPS certificate. Can you serve a file from here? (e.g. with a
location block that has a
root configuration statement). Does your load balancer work over HTTP fine?